Android Question Button click, conditions met, skips over condition

Bryanne Vega

Member
Licensed User
Longtime 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?


B4X:
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:
B4X:
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:

sorex

Expert
Licensed User
Longtime User
maybe this solves it?

B4X:
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
 
Upvote 0

Bryanne Vega

Member
Licensed User
Longtime 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.
 
Upvote 0
Top