-
howdy,
how do I have a text box, that after entering text and hitting the ENTER key, my code runs.
example.
Private Sub Text2_KeyPress(KeyAscii As Integer)
dim num as integer
num = text2.text
If KeyAscii = 13 Then
label1.caption = num +5
End If
End Sub
I don't know if this makes sense but I bet someone can
easily figure it out.
thanks
-
Try this.
Code:
Private Sub Text2_KeyPress(KeyAscii As Integer)
Dim num As Integer
num = Val(Text2.Text)
If KeyAscii = 13 Then
Label1.Caption = num + 5
End If
End Sub
-
What you have there should work. What's happening when you run it?
-
<?>
Bruce, Megatron is correct..you need a value for
math calculations.
It can't work...text2.text is string by default.
-
I'm sorry to disagree, but while it is poor code, the line num = text2.text will work just fine as long as the string is a numeric character or characters.