vb中怎么样将输入的字母转换成数字?()
admin
2023-07-14 07:24:22
'用isnumeric函数即可,比如判断text1.text是不是数字
If Not IsNumeric(Text1.Text) Then MsgBox 不是数字
在WORD里打好,复制粘贴到caption的属性里去
'打开VB,建一个窗体,代码写进去就可以了,结果显示在标题栏上。
'基本上能找出键盘上所有值,除了win键\Ctrl\Screen...等特殊功能键找不出来。
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 18 Then Me.Caption = Alt
If KeyCode = 16 Then Me.Caption = Shift
If KeyCode = 112 And KeyCode = 123 Then Me.Caption = F & KeyCode - 111
If KeyCode = 34 Then Me.Caption = PageDown
If KeyCode = 65 And KeyCode = 90 Then Me.Caption = Chr(KeyCode)
If KeyCode = 48 And KeyCode = 57 Then Me.Caption = 键盘上方: & KeyCode - 48
If KeyCode = 96 And KeyCode = 105 Then Me.Caption = 数字键盘: & KeyCode - 96
If KeyCode = 110 Then Me.Caption = 数字键盘:.
'......
'依次找出keycode对应的键位就是了。有规律的就按规律写了,
End Sub
最简单的一个办法。。。
放一个textbox。。。
什么代码都不用输,运行。。。
Private Sub Form_KeyPress(KeyAscii As Integer)
If Chr(KeyAscii) Then
Print Chr(KeyAscii)
End If
End Sub
textbox 的 IMEMode 属性改为 0-No Operation
这样就可以了
text2.text = Replace(text1.text, a, 1)
text2.text = Replace(text2.text, b, 2)
text2.text = Replace(text2.text, c, 3)
text2.text = Replace(text2.text, d, 4)
text2.text = Replace(text2.text, e, 5)
text2.text = Replace(text2.text, f, 6)
text2.text = Replace(text2.text, g, 7)
text2.text = Replace(text2.text, h, 8)
text2.text = Replace(text2.text, i, 9)
text2.text = Replace(text2.text, j, 10)
text2.text = Replace(text2.text, k, 11)
text2.text = Replace(text2.text, l, 12)
text2.text = Replace(text2.text, m, 13)
text2.text = Replace(text2.text, n, 14)
text2.text = Replace(text2.text, o, 15)
text2.text = Replace(text2.text, p, 16)
text2.text = Replace(text2.text, q, 17)
text2.text = Replace(text2.text, r, 18)
text2.text = Replace(text2.text, s, 19)
text2.text = Replace(text2.text, t, 20)
text2.text = Replace(text2.text, u, 21)
text2.text = Replace(text2.text, v, 22)
text2.text = Replace(text2.text, w, 23)
text2.text = Replace(text2.text, x, 24)
text2.text = Replace(text2.text, y, 25)
text2.text = Replace(text2.text, z, 26)
相关内容