在 keypress 事件里判断不行?
private sub text1_keypresss(assicc as long)
if assicc=13 then
debug.print "按了回车键"
end if
end sub
private sub text1_keypresss(assicc as long)
if assicc=13 then
debug.print "按了回车键"
end if
end sub
if KeyAscii =13 then
debug.print "按了回车键"
end ifEnd Sub
可以的嘛。
If KeyAscii = &HD Then
' 对数据进行处理
' ......
End If
End Sub
Private Sub Text3_KeyPress(keyascii As Integer, i As Integer)
If keyascii = 13 Then
Form2.Text3(i) = Hex(Val(Text3(i + 7)))//这句有问题吗?
End If
End Sub
If keyascii = 13 Then
Form2.Text3(i) = Hex(Val(Text3(i + 7)))//这句有问题吗?
Form2.Visible=True
End If
End Sub
MyHex = Hex(5) ' Returns 5.
MyHex = Hex(10) ' Returns A.
MyHex = Hex(459) ' Returns 1CB.
if assicc=13 then
…………
…………
end if
end sub
比如:Text1.text=Hex(10) ' 可以吗?
如果界面复杂的话也可以这样处理,不过要添加一个标志位来判断目前是不是在编辑文本框。代码如下:
Dim txteditflag As Boolean
Private Sub Command1_Click()
If txteditflag = True Then
MsgBox "you click return!"
txteditflag = False
Command1.SetFocus
End If
End SubPrivate Sub Form_Load()
txteditflag = False
Me.KeyPreview = True
Command1.Default = True
End SubPrivate Sub text1_GotFocus()
txteditflag = True
End SubPrivate Sub Text1_LostFocus()
txteditflag = True
End Sub
If KeyAscii = vbKeyReturn Then
Text1.Text = Hex(Val(Text1.Text))
KeyAscii = 0
End If
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then
Text1.Text = Hex(Val(Text1.Text))
End If
End SubText1能显示的
Private Sub Text3_KeyPress(keyascii As Integer, i As Integer)
'判断回车键是否按下
If keyascii = &HD Then
keyascii = 0
Text3(i).Text = Hex(Val(Text3(i + 7).Text))
'将10进制数转化为16进制数
End If
End Sub
难道是我定义的数组有问题?
'判断回车键是否按下
If keyascii = &HD Then
keyascii = 0
Text3(i).Text = Hex(Val(Text3(i + 7).Text))
'将10进制数转化为16进制数
End If
End Sub
i 最大为多少
若 dim text3(4) as string
点击text3(3)时
则Text3(i).Text = Hex(Val(Text3(i + 7).Text))
变为:Text3(3).Text = Hex(Val(Text3(10).Text))
超出数组定义
现在主要是这段代码根本没有检测到“Enter”键按下
我用Msgbox试过了