Is there anyway to trigger a button when the length of my textbox reach a length of 8 ?
For example, when i type the 8th character on the txtbox, it will automatically trigger a button.
thanks.
Printable View
Is there anyway to trigger a button when the length of my textbox reach a length of 8 ?
For example, when i type the 8th character on the txtbox, it will automatically trigger a button.
thanks.
Add this code to a form with a command button (named Command1)
and a text box (named Text1)
Code:Option Explicit
Private Sub Command1_Click()
MsgBox "The number of characters in the textbox is: " & Len(Text1.Text)
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) >= 8 Then
Call Command1_Click
End If
End Sub
Private Sub Command1_Click()
MsgBox "it works"
End Sub
Private Sub Text1_Change()
If Len(Text1.Text) = 8 Then Command1.Value = True
End Sub
VB Code:
Private Sub Text1_Change() If Len(Text1) > 7 Then Command1.Enabled = True End If End Sub
i would go with JohnVB.........
changing the value or making it enabled wont call the command's sub
Buggy,
I beg to differ. Setting the Command button's Value property to True will fire the button click event.
Check it out.
lol.. i always get stuff wrong.. sorry whoever asked the question, i misread it