Results 1 to 3 of 3

Thread: [RESOLVED] !!!!!!!Need Some Help !!!!!!Urget

  1. #1

    Thread Starter
    Fanatic Member newprogram's Avatar
    Join Date
    Apr 2006
    Location
    in your basement
    Posts
    769

    Resolved [RESOLVED] !!!!!!!Need Some Help !!!!!!Urget

    I need a little help with my code , If the statment is true I want it to stop the code at the end if what should I use in the place of the 'end if'?
    Private Sub Command20_Click()
    If Check1 = 1 Then 'if this is true i want it to stop
    Check1 =0
    Check2 = 1
    End If 'here
    If Check2 = 1 Then
    check2 = 0
    Check3 = 1
    End If
    If Check3 = 1 Then
    Check3 = 0
    check4 = 1
    End If
    End Sub

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: !!!!!!!Need Some Help !!!!!!Urget

    Use nested If Else statements.

    VB Code:
    1. Private Sub Command20_Click()
    2. If Check1 = 1 Then 'if this is true i want it to stop
    3.    Check1 =0
    4.    Check2 = 1
    5. Else
    6.    If Check2 = 1 Then
    7.       Check2 = 0
    8.       Check3 = 1
    9.    End If
    10.    If Check3 = 1 Then
    11.       Check3 = 0
    12.       check4 = 1
    13.    End If
    14. End If
    15. End Sub

    Or ElseIf statements

    VB Code:
    1. Private Sub Command20_Click()
    2. If Check1 = 1 Then 'if this is true i want it to stop
    3.    Check1 =0
    4.    Check2 = 1
    5. ElseIf Check2 = 1 Then
    6.       Check2 = 0
    7.       Check3 = 1
    8. ElseIf Check3 = 1 Then
    9.       Check3 = 0
    10.       check4 = 1
    11. End If
    12. End Sub

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

    Re: !!!!!!!Need Some Help !!!!!!Urget

    Or you may use Exit Sub/Function statement

    VB Code:
    1. If Check1 = 1 Then 'if this is true i want it to stop
    2.     Check1 = 0
    3.     check2 = 1
    4.     Exit Sub
    5. End If 'here
    6. If check2 = 1 Then
    7.     check2 = 0
    8.     Check3 = 1
    9. End If
    10. If Check3 = 1 Then
    11.     Check3 = 0
    12.     check4 = 1
    13. End If
    14. End Sub

    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...

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