[RESOLVED] on KeyPress error
Hi all,
Just a quick problem -
I have a program that has a text box take focus when the program loads. I want it to display some text, which dissapears if you click / get focus in the box. Kinda like a lable. I also DON'T want it to make the label text dissapear when the program loads. I accheived this with the following code:
Code:
' Global declare thingy
Dim AA as Boolean
' More code
Private Sub MD51in_GotFocus()
If AA = False Then
AA = True
Exit Sub
End If
If MD51in.Text = "Actual MD5 Checksum" Then
MD51in.Text = ""
MD51in.SetFocus
End If
End Sub
Private Sub MD51in_LostFocus()
If MD51in.Text = "" Then
MD51in.Text = "Actual MD5 Checksum"
End If
End Sub
Private Sub MD52in_GotFocus()
If MD52in.Text = "Supposed MD5 Checksum" Then
MD52in.Text = ""
MD52in.SetFocus
End If
End Sub
Private Sub MD52in_LostFocus()
If MD52in.Text = "" Then
MD52in.Text = "Supposed MD5 Checksum"
End If
End Sub
However, I have noticed that if you start typing in that box right away, the "lable text" will remain. I tried countering this using an _change()..
Code:
Private Sub MD51in_Change()
If MD51in.Text = "Actual MD5 Checksum" Then
MD51in.Text = ""
MD51in.SetFocus
End If
End Sub
But it didn't work. The best solution I can think of is to use _KeyPress or _KeyDown:
Code:
Private Sub MD51in_KeyPress()
If MD51in.Text = "Actual MD5 Checksum" Then
MD51in.Text = ""
MD51in.SetFocus
End If
End Sub
But if I try that, it gives the following error:
http://www.arbital24.com/Pics/VBForums/Ackdecthing.jpg
Any ideas? :)