关于VB: 我想让几个textbox执行同一个语句,请问我应该怎样设置
具体是:我设这几个textbox的index为0,1,2,3这几个textbox的名称都为Text1然后我在其中一个textbox中写入:PrivateSubText1_...
具体是:我设这几个textbox的index为0,1,2,3
这几个textbox的名称都为Text1
然后我在其中一个textbox中写入:
Private Sub Text1_KeyPress(KeyAscii As Integer, Index As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102)) Then
KeyAscii = 0
End If
End Sub
语句的意思是:textbox中只能写入0123456789abcdef
但这个功能无法执行
请各位大佬帮帮小弟 展开
这几个textbox的名称都为Text1
然后我在其中一个textbox中写入:
Private Sub Text1_KeyPress(KeyAscii As Integer, Index As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102)) Then
KeyAscii = 0
End If
End Sub
语句的意思是:textbox中只能写入0123456789abcdef
但这个功能无法执行
请各位大佬帮帮小弟 展开
展开全部
Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102)) Then
KeyAscii = 0
End If
End Sub
用这段代码试试看,在我这边可行的。
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102)) Then
KeyAscii = 0
End If
End Sub
用这段代码试试看,在我这边可行的。
展开全部
可以的啊 能通过调试啊 无法执行表现为什么啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Text1_KeyPress(KeyAscii As Integer)
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102)) Then
KeyAscii = 0
End If
End Sub
就这样了啊,你上面哪个Private Sub Text1_KeyPress(KeyAscii As Integer, ) 中的Index As Integer去掉就行了
If Not ((KeyAscii >= 48 And KeyAscii <= 57) Or (KeyAscii >= 65 And KeyAscii <= 70) Or (KeyAscii >= 97 And KeyAscii <= 102)) Then
KeyAscii = 0
End If
End Sub
就这样了啊,你上面哪个Private Sub Text1_KeyPress(KeyAscii As Integer, ) 中的Index As Integer去掉就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private
Sub
Text1_KeyPress(Index
As
Integer,
KeyAscii
As
Integer)
If
Not
((KeyAscii
>=
48
And
KeyAscii
<=
57)
Or
(KeyAscii
>=
65
And
KeyAscii
<=
70)
Or
(KeyAscii
>=
97
And
KeyAscii
<=
102))
Then
KeyAscii
=
0
End
If
End
Sub
用这段代码试试看,在我这边可行的。
Sub
Text1_KeyPress(Index
As
Integer,
KeyAscii
As
Integer)
If
Not
((KeyAscii
>=
48
And
KeyAscii
<=
57)
Or
(KeyAscii
>=
65
And
KeyAscii
<=
70)
Or
(KeyAscii
>=
97
And
KeyAscii
<=
102))
Then
KeyAscii
=
0
End
If
End
Sub
用这段代码试试看,在我这边可行的。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询