VB计算器+-*/怎么用键盘响应
来源:百度知道 编辑:UC知道 时间:2024/05/27 07:04:13
怎么用键盘响应+-*/几个键盘?keyup和keydown怎么做啊
用Form的keydown()函数
如果你希望在Text控件里存储此响应,比如你的响应的Text控件名为 txtOperator
那么
private sub form_keydown(keycode as integer,shift as integer)
If keycode=ascii("+") Then
txtOperator.text=txtOperator.text & "+"
End If
If keycode=ascii("-") Then
txtOperator.text=txtOperator.text & "-"
End If
If keycode=ascii("*") Then
txtOperator.text=txtOperator.text & "*"
End If
If keycode=ascii("/") Then
txtOperator.text=txtOperator.text & "/"
End If
end sub
记得要把form属性中的keypreview 改成True