Consulting

Results 1 to 4 of 4

Thread: Ghost button until valid entry

  1. #1
    VBAX Newbie
    Joined
    Sep 2015
    Posts
    2
    Location

    Cool Ghost button until valid entry

    Hello,
    My program asks for an input (probably using an input box, but maybe something else would work better for this), and I want to make the Okay button ghosted out and unclickable until the entry is the right length of characters.

    I know I could just pop up a box that says "Wrong length" and return them to the entry box, but that's not as sleek as I'd like.
    Is there a way to do this?

    Thanks!

  2. #2
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    You can do that with a user form


    Option Explicit
    
    Private Sub butCancel_Click()
        Me.Hide
        Unload Me
    End Sub
    
    Private Sub butOK_Click()
        MsgBox "That's 8 characters"
        Me.Hide
        Unload Me
    End Sub
     
    Private Sub tbEntry_Change()
        With Me
            .labCounter.Caption = Len(.tbEntry.Text)
            If .labCounter.Caption = "8" Then
                .butOK.Enabled = True
            Else
                .butOK.Enabled = False
            End If
        End With
    End Sub
    
    Private Sub UserForm_Initialize()
        With Me
            .butOK.Enabled = False
            .labCounter.Caption = "0"
        End With
    End Sub
    Attached Files Attached Files
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

  3. #3
    VBAX Newbie
    Joined
    Sep 2015
    Posts
    2
    Location

    Not quite there

    Thanks Paul!

    I think by looking up tutorials on user forms I can figure out the details.

  4. #4
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,728
    Location
    OK

    Ask any questions

    UFs are nice and flexible for things like this, plus you can add all the polish and eye candy you want (pictures, logos, frames, options, command button caption changes, etc.)
    ---------------------------------------------------------------------------------------------------------------------

    Paul


    Remember: Tell us WHAT you want to do, not HOW you think you want to do it

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums
    http://www.vbaexpress.com/forum/faq...._new_faq_item3

Tags for this Thread

Posting Permissions

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