Results 1 to 4 of 4

Thread: Quick help please.

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Devon, UK
    Posts
    311

    Quick help please.

    hi this is probably simple, but i can't figure it.

    How do i make a button only enabled when all 4 of my text boxes have something written in them.

    ay the mo i am trying:

    command1.enabled=false

    if text1.datachanged=true & text2.datachanged=true & _
    text3.datachanged=true & text4.datachanged=true then
    command1.enabled=true
    endif

    But it don't work

    please help.
    Sam.

  2. #2
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Code:
    If txt1.Text <> "" AND txt2.Text <> "" AND txt3.Text <> "" AND txt4.Text <> "" Then
    'do this
    else
    command1.enabled = True
    end if
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Sub VerifyEntries()
    2. 'hack
    3. 'This works by multiplying the lengths of the required fields together.  If any field is empty, the result sum
    4. 'will be 0.   VB treats a 0 as false and non-zero as true.   Therefore, when all of the fields have an entry
    5. 'the sum will be greater than 0, hence, True and the command button will become enabled
    6. Command1.Enabled = Len(Trim$(Text1.Text)) * Len(Trim$(Text2.Text)) * _
    7. Len(Trim$(Text3.Text)) * Len(Trim$(Text4.Text)
    8. End Sub
    9.  
    10. Private Sub Text1_Change()
    11. VerifyEntries
    12. End Sub
    13.  
    14. Private Sub Text2_Change()
    15. VerifyEntries
    16. End Sub
    17.  
    18. Private Sub Text3_Change()
    19. VerifyEntries
    20. End Sub
    21.  
    22. Private Sub Tex4_Change()
    23. VerifyEntries
    24. End Sub

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2002
    Location
    Devon, UK
    Posts
    311
    thanks allot it works now, dunb ass me, why didn't i think of greater than




    thx
    Sam.

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