Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. nested if statement

nested if statement

Scheduled Pinned Locked Moved Visual Basic
javahelptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    malcomhfc
    wrote on last edited by
    #1

    Ive had a google about nexted if statements but failing to find what i need, or just am not awake to find it :laugh: So here is an example of what i need help with

    if textbox1.text = "example" then
    if textbox2.text = "another example then
    so on.....

    END IF

    I have done it it java just not sure in VB, in a quick way, when system runs the if statement, if the first if passes then go onto the second if statement. Could anyone help me out on the correct syntax?

    L 1 Reply Last reply
    0
    • M malcomhfc

      Ive had a google about nexted if statements but failing to find what i need, or just am not awake to find it :laugh: So here is an example of what i need help with

      if textbox1.text = "example" then
      if textbox2.text = "another example then
      so on.....

      END IF

      I have done it it java just not sure in VB, in a quick way, when system runs the if statement, if the first if passes then go onto the second if statement. Could anyone help me out on the correct syntax?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      You seem on the right path, I don't understand the statement..

      If x = 1 Then
      If y = 2 Then
      If z = 3 Then
      z = 4
      y = 5
      x = 6
      End If
      End If
      End If

      Assume x = 1 y = 2 z = 4 Then the first two If statements pass as true but the last If statement, the test on if z = 3 fails, so x,y and z never get changed past 1,2 and 4 respectively. Did this help?

      Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

      M 1 Reply Last reply
      0
      • L Lost User

        You seem on the right path, I don't understand the statement..

        If x = 1 Then
        If y = 2 Then
        If z = 3 Then
        z = 4
        y = 5
        x = 6
        End If
        End If
        End If

        Assume x = 1 y = 2 z = 4 Then the first two If statements pass as true but the last If statement, the test on if z = 3 fails, so x,y and z never get changed past 1,2 and 4 respectively. Did this help?

        Check out the CodeProject forum Guidelines[^] The original soapbox 1.0 is back![^]

        M Offline
        M Offline
        malcomhfc
        wrote on last edited by
        #3

        Ah right ofc makes sense i was missing out End If and you explain very good. Thanks :)

        L 1 Reply Last reply
        0
        • M malcomhfc

          Ah right ofc makes sense i was missing out End If and you explain very good. Thanks :)

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          you should also notice how proper indentation improves readability a lot. Most code editors can do that automatically for you. :)

          Luc Pattyn


          Have a look at my entry for the lean-and-mean competition; please provide comments, feedback, discussion, and don’t forget to vote for it! Thank you.


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups