Results 1 to 21 of 21

Thread: help! multiple if conditions?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    help! multiple if conditions?

    ok... I want my program to check all "Checkboxes" - which it does... but I want it to check throughout the program (i used a timer) to see if ALL the checkboxes are checked. However, I am not too sure about how I would basically say:

    If check1, check2 AND check3.value = true then
    msgbox ....
    end if...

    please help
    Last edited by twostars; Jun 11th, 2005 at 05:47 AM.

  2. #2

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    actually, I will rephrase that....

    I want it to somehow check if all 3 checkboxes are checked at the same time...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    anyone?

  4. #4
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: help! multiple if conditions?

    Quote Originally Posted by twostars
    ok... I want my program to check all "Checkboxes" - which it can do... but I want it to check throughout the program (i used a timer) to see if ALL the checkboxes are checked. However, I am not too sure about how I would basically say:

    If check1, check2 AND check3.value = true then
    msgbox ....
    end if...

    please help
    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim chk As Control
    3.     For Each chk In Me.Controls
    4.         If TypeOf chk Is CheckBox Then
    5.             If chk.Value = vbUnchecked Then
    6.                 MsgBox chk.Name & " is Unchecked."
    7.                 Exit For
    8.             End If
    9.         End If
    10.     Next
    11. End Sub
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  5. #5

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    ? I want it to check by itself... with a timer

  6. #6

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    I want it to ONLY make a messagebox appear when they are all checked... can you change that code to do it?

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: help! multiple if conditions?

    you could just put pradeep code into a timer event, or you could use the checkboxes own click event to check each time a box is check if all boxes are checked

    pete

  8. #8

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    how do you activate the click event?

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: help! multiple if conditions?

    Private Sub Check1_Click()
    'put your code here
    End Sub

    edit: you will need to do for each checkbox
    pete

  10. #10

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    Private Sub Check1_Click()
    'put your code here
    End Sub
    but what do I need inside them?! lol

  11. #11

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    anybody????

  12. #12
    Frenzied Member
    Join Date
    Oct 2003
    Posts
    1,301

    Re: help! multiple if conditions?

    No need to bump the thread every 5 minutes.

    VB Code:
    1. Dim chk As Control
    2. Dim AllChecked As Boolean
    3.   AllChecked = True
    4.   For Each chk In Me.Controls
    5.     If TypeOf chk Is CheckBox Then
    6.       chk.Value = vbUnchecked Then
    7.         AllChecked = False
    8.         Exit For
    9.       End If
    10.     End If
    11.   Next
    12.   If AllChecked = True Then MsgBox "All"

  13. #13

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    it doesnt recognise or like the vbunchecked bit - the whole line

  14. #14
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: help! multiple if conditions?

    Quote Originally Posted by twostars
    anybody????
    VB Code:
    1. Private Sub CheckNow()
    2.     Dim chk As Control
    3.     For Each chk In Me.Controls
    4.         If TypeOf chk Is CheckBox Then
    5.             If chk.Value = vbUnchecked Then
    6.                 MsgBox chk.Name & " is Unchecked."
    7.                 Exit For
    8.             End If
    9.         End If
    10.     Next
    11. End Sub
    12.  
    13. Private Sub Check1_Click()
    14.     CheckNow
    15. End Sub
    16.  
    17. Private Sub Check2_Click()
    18.     CheckNow
    19. End Sub
    20.  
    21. Private Sub Check3_Click()
    22.     CheckNow
    23. End Sub
    24.  
    25. Private Sub Check4_Click()
    26.     CheckNow
    27. End Sub
    28. .
    29. .
    30. .


    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  15. #15

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    thx pradeep, although it still doesnt quite work... if check3 is unchecked; for some reason check2 UNCHECkS?

  16. #16

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    dont worry bout it guys... I give up lol

  17. #17

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    *sigh*

  18. #18
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: help! multiple if conditions?

    Please stop spamming. I don't have a clue why Pradeeps code doesn't work for you . Can you please explain clearly what effect you are after, and how it doesn't work, and then I will try to help you.

  19. #19
    Banned ThaRubby's Avatar
    Join Date
    Apr 2005
    Location
    127.0.0.1
    Posts
    356

    Re: help! multiple if conditions?

    Are you looking for...

    If Option1.Value = True And Option2.Value = True And Option3.Value = True Then
    MsgBox "Meh"
    End If


    ??

    To enable a time its Timer1.Enabled = True

  20. #20
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: help! multiple if conditions?

    Quote Originally Posted by twostars
    *sigh*
    Instead of sighing, which does no one any good, why don't you post the code you are using? Thus far, all I've seen is code posted to help you, but I've not seen anything from you indicating what you are doing with the code.

  21. #21

    Thread Starter
    Junior Member
    Join Date
    May 2005
    Posts
    23

    Re: help! multiple if conditions?

    ThaRubby - that is EXACTLY what I mean! (is it possible)

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