Android Question Button click, conditions met, skips over condition

Discussion in 'Android Questions' started by Bryanne Vega, May 19, 2015.

  1. Bryanne Vega

    Bryanne Vega Member Licensed User

    While the value is between 1-2 it works, if it hits 3 or more it wont work it skips over the first IF. Why?


    Code:
    Sub cmdBack_Click
        
    If CurrentStepCount <= 2  Then
            cmdBack.visible=
    True
            cmdNext.visible=
    True
            CurrentStepCount = CurrentStepCount - 
    1
            
    Dim links As Map
            links.Initialize
            links.Put(imageBox,
    "http://" & urlDirectory & CurrentStepCount & ".png")
            CallSubDelayed2(ImageDownloader, 
    "Download", links)
            tutorialLabel.Text = StepText(CurrentStepCount)
        
    End If
        
    If CurrentStepCount = 1 Then
            
    Dim links As Map
            links.Initialize
            links.Put(imageBox,
    "http://" & urlDirectory & CurrentStepCount & ".png")
            CallSubDelayed2(ImageDownloader, 
    "Download", links)
            tutorialLabel.Text = StepText(CurrentStepCount)
            cmdBack.Visible=
    False
            cmdNext.Visible=
    True
        
    End If
    End Sub
    Here is my NEXT button click:
    Code:
    Sub cmdNext_Click
        
    If (CurrentStepCount < TutorialStepCount) Then
            CurrentStepCount = CurrentStepCount + 
    1
            
    Dim links As Map
            links.Initialize
            links.Put(imageBox, 
    "http://" & urlDirectory & CurrentStepCount & ".png")
            CallSubDelayed2(ImageDownloader, 
    "Download", links)
            tutorialLabel.Text = StepText(CurrentStepCount)
            cmdNext.visible=
    True
            cmdBack.Visible=
    True
        
    End If
        
    If CurrentStepCount = TutorialStepCount Then
            tutorialLabel.Text = StepText(CurrentStepCount)
            cmdNext.visible=
    False
            cmdBack.Visible=
    True
        
    End If
    End Sub
    What I achieve from this is navigating through a web folder, getting the previous or next image and displaying it on the image view, while disabling/enabling the forward/back buttons at the start or the end of the tutorial's steps (ex: 1-5)
     
    Last edited: May 19, 2015
  2. sorex

    sorex Expert Licensed User

    maybe this solves it?

    Code:
    Sub cmdBack_Click
    getImage(-stepcount)
    End Sub

    Sub cmdNext_Click
    getImage(stepcount)
    End Sub

    Sub getImage(sc as int)
    CurrentStepCount=CurrentStepCount+sc

    if CurrentStepCount<=1 then
    CurrentStepCount=
    1
    cmdNext.visible=
    True
    cmdBack.visible=
    False
    end if

    if CurrentStepCount>=5 then
    CurrentStepCount=
    5
    cmdBack.visible=
    True
    cmdNext.visible=
    False
    end if

    Dim links As Map
    links.Initialize
    links.Put(imageBox,
    "http://" & urlDirectory & CurrentStepCount & ".png")
    CallSubDelayed2(ImageDownloader, 
    "Download", links)
    tutorialLabel.Text = StepText(CurrentStepCount)
    end sub
     
  3. Bryanne Vega

    Bryanne Vega Member Licensed User

    The merchants wont be able to go back and forth, but then again my steps are not long so it works, thanks for the prompt reply.
     
  4. sorex

    sorex Expert Licensed User

    they would be able to get back and forth if you set that stepcount value to 1 or more ;)
     
    Peter Simpson likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice