|
-
Sep 2nd, 2006, 03:00 AM
#1
Thread Starter
Hyperactive Member
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,
-
Sep 2nd, 2006, 03:12 AM
#2
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.
-
Sep 2nd, 2006, 03:13 AM
#3
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
-
Sep 2nd, 2006, 03:14 AM
#4
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
_____________________________________________________________________
----If this post has helped you. Please take time to Rate it.
----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.

-
Sep 2nd, 2006, 03:16 AM
#5
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
-
Sep 2nd, 2006, 03:32 AM
#6
Re: how to get the length of entered data in a text box
Have we given the sollution?
-
Sep 2nd, 2006, 04:14 AM
#7
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|