Computing.Net > Forums > Programming > VB6.......Dead Lock in Text Boxes

VB6.......Dead Lock in Text Boxes

Reply to Message Icon

Original Message
Name: gardenair
Date: February 12, 2003 at 18:10:40 Pacific
Subject: VB6.......Dead Lock in Text Boxes
OS: win98
CPU/Ram: 166
Comment:

My problem is that i have two text boxes to write input in it.
i have restricted the user to put characters in the valid text boxes.If the user input his name
then he will switch to the next text box by using setfocus.

For vaid input in the box i use

Private Sub text1_KeyPress(KeyAscii As Integer)
If (KeyAscii = 32) Then 'For giving Space between words
Exit Sub
ElseIf (KeyAscii >= 65 And KeyAscii = 65 And KeyAscii = 90) Then
Exit Sub
ElseIf (KeyAscii = 8) Then ' For Bakspace key
Exit Sub
ElseIf (KeyAscii = 13) Then
text3.SetFocus
KeyAscii = 0
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub

To restrict the user to input characters which would not be less than three charcators in text2
i use Lost focus of text2.

Private Sub text2_LostFocus()
If Len(text2.Text) 4 Then
MsgBox "Please Enter Valid Information...........text2", vbInformation, "Message Box Window"
text2.SetFocus
End If
End Sub

The problem rises which i put less than 3 characters in text1 txtbox, suppose i want to
write "jone" but unconciously i write "jo" in text1 then a deadlock occure of the following messages
which i write in the lostFocus of text1 & text2.

"Please Enter Valid Information...........text1" 'LostFocus of text1 Activate.
"Please Enter Valid Information...........text2" 'LostFocus of text2 Activate.

These messages appears again and again the cusor switch text1 & then text2 with the above
messages & i have only one way to quite from this Deadlock
by using Aly+Ctrl+Del
Please help me ...How can i get ride of from this problem.
Bundle of thanks.


Report Offensive Message For Removal

Response Number 1
Name: iet-guy
Date: February 13, 2003 at 18:31:56 Pacific
Subject: VB6.......Dead Lock in Text Boxes
Reply: (edit)

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii >= Asc("A") And KeyAscii = Asc("a") And KeyAscii = Asc("z") _
Or KeyAscii = 8 Or KeyAscii = 32 Then
Exit Sub
ElseIf (KeyAscii = 13) Then
Text3.SetFocus
KeyAscii = 0
Exit Sub
Else
KeyAscii = 0
Beep
End If
End Sub
Private Sub Text2_LostFocus()
If Len(Text2.Text) 3 Then
MsgBox "Please Enter Valid Information...Text2", vbInformation, "Message
Box Window"
Text2.SetFocus
Exit Sub
End If
End Sub


Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: VB6.......Dead Lock in Text Boxes

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software