C colin9876 Active Member Licensed User Nov 18, 2007 #1 Really Basic BASIC question why doesnt this code work if n=0 then msgbox("No") else msgbox("yes") The if part works on its own but ive somehow got the else condition wrong because it doesnt work when I add that part? Also if I want to do 2 things after an if how do I combine them so it does both on condition of that if? e.g if n=0 then msgbox("No") and x=1
Really Basic BASIC question why doesnt this code work if n=0 then msgbox("No") else msgbox("yes") The if part works on its own but ive somehow got the else condition wrong because it doesnt work when I add that part? Also if I want to do 2 things after an if how do I combine them so it does both on condition of that if? e.g if n=0 then msgbox("No") and x=1
P petrbury Member Licensed User Longtime User Nov 18, 2007 #2 Hi, try If n=0 Then Msgbox("No") Else Msgbox("yes") End If it should work. The second question : If condition Then action1 action2 . . actionx End If Regards Petr
Hi, try If n=0 Then Msgbox("No") Else Msgbox("yes") End If it should work. The second question : If condition Then action1 action2 . . actionx End If Regards Petr
Erel B4X founder Staff member Licensed User Longtime User Nov 19, 2007 #3 There are two syntaxes: B4X: If n = 0 then msgbox("No") else msgbox("yes") 'Single line or: B4X: If n=0 then msgbox("no") ... else if n = 1 then ... else if ... then ... else ... end if
There are two syntaxes: B4X: If n = 0 then msgbox("No") else msgbox("yes") 'Single line or: B4X: If n=0 then msgbox("no") ... else if n = 1 then ... else if ... then ... else ... end if
C colin9876 Active Member Licensed User Nov 19, 2007 #4 Thanks - very helpful. I see it was because I had the IF ELSE over two lines that it didnt work - much appreciated
Thanks - very helpful. I see it was because I had the IF ELSE over two lines that it didnt work - much appreciated