how to get the length of entered data in a text box
Hi,
Can any one please guide me that hw to take the length of the entered data in a text box so that its length can be checked?Actually I have restricted a text box data length by using its property of Max length,the next step is to set focus to the next text box..so please guide me.
Regards,
Re: how to get the length of entered data in a text box
Use the Len() function
VB Code:
If Len(Text1.Text) = 10 Then 'change the 10 to suit the length of yours
Text2.SetFocus
End If
casey.
Re: how to get the length of entered data in a text box
VB Code:
Private Sub Command1_Click()
'Displays the length of the text entered in the text box
'Len <--- To get the length
'Trim <-- Trim the text box string
MsgBox Len(Trim(Text1.Text))
'moves the control to the Text box called Text2
Text2.SetFocus
End Sub
Re: how to get the length of entered data in a text box
VB Code:
If Len(text1.text) = 10 then ''Assuming Max property is set to 10
text2.setfocus 'if textbox1 contains 10 characters set the focus to text2
Else
Msgbox "Please Enter a max of 10 Characters"
End if
Re: how to get the length of entered data in a text box
VB Code:
Private Sub Text1_KeyPress(KeyAscii As Integer)
'This will move the focus if the lenght of the text is equal to 10
If Len(Text1.Text) = 10 Then
Text2.SetFocus
End If
End Sub
Re: how to get the length of entered data in a text box
Have we given the sollution?
Re: how to get the length of entered data in a text box
VB Code:
Private Sub Text1_Change()
If [B]Len(Text1.Text)=Text1.MaxLength[/B] Then
Text2.SetFocus
Else
MsgBox "Enter more..."
End If
End Sub