Results 1 to 7 of 7

Thread: 1 Question On TextBox. Help.

  1. #1

    Thread Starter
    Member
    Join Date
    May 2002
    Posts
    45

    1 Question On TextBox. Help.

    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.

  2. #2
    Hyperactive Member
    Join Date
    May 2002
    Location
    Chicago
    Posts
    271
    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
    Sometimes what you're looking for is exactly where you left it.

  3. #3
    Hyperactive Member Ed Lampman's Avatar
    Join Date
    Mar 2001
    Posts
    273
    Private Sub Command1_Click()

    MsgBox "it works"
    End Sub

    Private Sub Text1_Change()

    If Len(Text1.Text) = 8 Then Command1.Value = True

    End Sub

  4. #4
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    VB Code:
    1. Private Sub Text1_Change()
    2.      If Len(Text1) > 7 Then
    3.           Command1.Enabled = True
    4.      End If
    5. End Sub
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    i would go with JohnVB.........

    changing the value or making it enabled wont call the command's sub
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6
    Hyperactive Member Ed Lampman's Avatar
    Join Date
    Mar 2001
    Posts
    273
    Buggy,

    I beg to differ. Setting the Command button's Value property to True will fire the button click event.

    Check it out.

  7. #7
    Lively Member DJ P@CkMaN's Avatar
    Join Date
    Jan 2002
    Location
    Burpengary, Queensland, Australia
    Posts
    95
    lol.. i always get stuff wrong.. sorry whoever asked the question, i misread it
    There's something I've noticed in the last year or so...
    Australian's are good at EVERYTHING !!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width