大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
可以,用VB自带函数就可以了半角转全角:Text2.Text = StrConv(Text1.Text, )全角转半角:Text2.Text = StrConv(Text1.Text,vbNarrow)当然你可以做得智能一点,譬如只允许输入数字、符号和字母什么的。
成都创新互联公司长期为超过千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为易县企业提供专业的成都网站设计、成都网站建设,易县网站改版等技术服务。拥有10多年丰富建站经验和众多成功案例,为您定制开发。
string str1 = "a=1.2,3.5,7.88";
var arr = (from s in str1.Split('=')[1].Split(',') where s.Trim() != "" select Convert.ToDouble(s)).ToArray();
Split(',')这个地方逗号是全角还是半角的按照你文本内容里面的来
(1)在Form1上布置一个Label,用来显示键盘码
(2)窗体代码如下
Imports System.Windows.Forms
Imports System.IO
Imports System.Net
Imports System.Windows.Forms
Imports System.IO
Imports System.Net
Public Class Form1
Private Sub Form1_Load(sender As Object,
e As EventArgs) Handles MyBase.Load
KeyPreview = True
End Sub
Private Sub Form1_KeyDown(sender As Object,
e As KeyEventArgs) Handles MyBase.KeyDown
Label1.Text = e.KeyValue
End Sub
End Class
按键盘上的键,Label1将显示对应键的键盘码
明白你的意思了,只要是字母都会转换成数字,帮你写好了("usernane"和 "pasward" 我这里写成 "username" 和" password")
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim username, password As String
Dim temp As Long
Dim r As String = ""
Dim v As String = TextBox1.Text
For Each c In v.ToString
If IsNumeric(c) Then
r = c
Else
r = ((Asc(c) - 65).ToString("00"))
End If
Next
username = r
temp = username * 3 - 500
password = CStr(temp)
TextBox2.Text = password
End Sub
你可以用 Encoding 对象转。先用 Encoding.Unicode 转成 Byte(),再转回 Ansi。
也可以自己写代码,把/u替换为H,再逐个用ChrW()函数取得汉字即可。
字符编码转换吗?
1.字符与gb2312(gbk的子集):
Public Function GBKEncode(ByVal sInput As String) As String
Dim ret_GBKEncode As String = ""
Dim i As Integer
Dim startIndex As Integer = 0
Dim endIndex As Integer
Dim x() As Byte = System.Text.Encoding.Default.GetBytes(sInput) '字符以及字符串在vb2008中都是以unicode编码存储的
endIndex = x.Length - 1
For i = startIndex To endIndex
ret_GBKEncode = "%" Hex(x(i))
Next
Return ret_GBKEncode
End Function
'GBK解码
Public Function GBKDecode(ByVal sInput As String) As String
sInput = sInput.Replace("%", "")
Dim ret_GBKDecode As String = ""
Dim sLen As Integer = sInput.Length
Dim n As Integer = sLen \ 2
Dim sBytes(0 To n - 1) As Byte
'转化为字节码
For i As Integer = 1 To n
sBytes(i - 1) = CByte("H" sInput.Substring(2 * i - 2, 2))
Next
'将字节码转化为字符串
ret_GBKDecode = System.Text.Encoding.Default.GetString(sBytes)
Return ret_GBKDecode
End Function
2.Unicode字符串为UTF-8
Imports System.Text
Public Function StringAsUtf8Bytes(ByVal strData As String) As Byte()
Dim bytes() As Byte
bytes = Encoding.UTF8.GetBytes(strData)
Return bytes
End Function
'这里可以类推出好几种。