I have typing the textbox more then 13 character. How I can trancate this character to 8 character?
For example "ABCDEFGHIJKCVBNE" will become "ABCDEFGH"
If Len(TxtKrigRasterWorkspace.Text) >= 13 Then
Printable View
I have typing the textbox more then 13 character. How I can trancate this character to 8 character?
For example "ABCDEFGHIJKCVBNE" will become "ABCDEFGH"
If Len(TxtKrigRasterWorkspace.Text) >= 13 Then
Set MaxLength property to whatever number you wish:
Code:Private Sub Form_Load()
Text1.MaxLength = 10
End Sub
You can also set the MaxLength property of the textbox at design-time.
How to pop up with messagebox when the input reach to maximum?
Quote:
Originally Posted by matrik02
Code:Private Sub Text1_Change()
If Len(Text1.Text) > 8 Then MsgBox "Something"
End Sub
What I understand from above is that no matter what the user enters you want only the 1st 8 characters. If yes, then is this what you want?Quote:
Originally Posted by matrik02
by the way Trim suppresses the leading and trailing spaces...Code:Sub aaa()
If Len(Trim(TxtKrigRasterWorkspace.Text)) >= 13 Then
TxtKrigRasterWorkspace.Text = Left(Trim(TxtKrigRasterWorkspace.Text), 8)
End If
End Sub
Why messagebox? They are annoying. :sick:Quote:
Originally Posted by matrik02
Show the tooltip instead (something like "Maximum number of characters allowed is 10")
How to show tooltip?
It's property (most controls have it) that you can set at design or runtime.
How can i show tooltip?
:confused: :confused: :confused:
Quote:
Originally Posted by RhinoBull
I know how can i show it, but is there any way to show it if condition is met.Quote:
Originally Posted by RhinoBull
Lets say
If Len(Text1.Text) = 10 then show text1.tooltip
TryCode:Private Sub Text1_Change()
If Len(Text1.Text) <> 8 Then
Text1.ToolTipText = vbNullString
Else
Text1.ToolTipText = "You can only have 8 characters in the textbox"
End If
End Sub
TryCode:Private Sub Text1_Change()
If Len(Text1.Text) <> 8 Then
Text1.ToolTipText = vbNullString
Else
Text1.ToolTipText = "You can only have 8 characters in the textbox"
End If
End Sub
Also, if you set the MaxLength property, either in code as Rhino has suggested, or in the design-time property sheet as I have suggested, you will not need to show a message of any kind, as the user will simply not be able to enter any more text into the box.
Exactly. :afrog: Which is why I suggested tooltip. :)Quote:
Originally Posted by BruceG