请教VB编程
来源:百度知道 编辑:UC知道 时间:2024/06/06 16:58:40
Private Sub Command1_Click()
Combo1.AddItem Text1.Text
Text1.Text = ""
End Sub
Private Sub Form_Load()
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'If KeyAscii > 57 Or KeyAscii < ? Then
MsgBox "请输入数字!"
' KeyAscii = ?
End If
End Sub
?怎么填啊
Combo1.AddItem Text1.Text
Text1.Text = ""
End Sub
Private Sub Form_Load()
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
'If KeyAscii > 57 Or KeyAscii < ? Then
MsgBox "请输入数字!"
' KeyAscii = ?
End If
End Sub
?怎么填啊
Private Sub Command1_Click()
Combo1.AddItem Text1.Text
Text1.Text = ""
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii > 57 Or KeyAscii < 48 Then
MsgBox "请输入数字!"
KeyAscii = 0
End If
End Sub
数字的ASC码是48到57
所以应改为
'If KeyAscii > 57 Or KeyAscii <48 Then
MsgBox "请输入数字!"
' KeyAscii = ?
这个就不需要了吧
如果要显示的话可以用
s=keyascii
chr(s)---即为ASC对应的字符
填48
原因:0对应的Ascii值是48