Yves Mazzon Member Licensed User Longtime User Sep 10, 2015 #1 If you have many conditions to check can you put them all in a single if? For example if label1.text ="" and label2.text="" and lable3.text = "" then Msgbox("Missing data", "Please fill all the boxes"). Maybe the way I show it is not right. What I wanted to do is when the operator click ok and the program start calculating the various entries you get a warning that some entries are missing. Many thanks Yves
If you have many conditions to check can you put them all in a single if? For example if label1.text ="" and label2.text="" and lable3.text = "" then Msgbox("Missing data", "Please fill all the boxes"). Maybe the way I show it is not right. What I wanted to do is when the operator click ok and the program start calculating the various entries you get a warning that some entries are missing. Many thanks Yves
Erel B4X founder Staff member Licensed User Longtime User Sep 10, 2015 #2 Yes, it is possible. Upvote 0
RandomCoder Well-Known Member Licensed User Longtime User Sep 10, 2015 #3 Yes this is fine. It is also useful in some instances because the If condition will stop at the first false condition, this can have nice speed benifits. Upvote 0
Yes this is fine. It is also useful in some instances because the If condition will stop at the first false condition, this can have nice speed benifits.
M Mahares Expert Licensed User Longtime User Sep 10, 2015 #4 Yves Mazzon said: For example if label1.text ="" and label2.text="" and lable3.text = "" then Click to expand... I am not sure if you are aware that the way yo have it, the message appears only when all labels are empty. But if you want the message to appear if any of them is blank, you need to do this: Code: Copy if label1.text ="" or label2.text="" or lable3.text = "" then Upvote 0
Yves Mazzon said: For example if label1.text ="" and label2.text="" and lable3.text = "" then Click to expand... I am not sure if you are aware that the way yo have it, the message appears only when all labels are empty. But if you want the message to appear if any of them is blank, you need to do this: Code: Copy if label1.text ="" or label2.text="" or lable3.text = "" then
wonder Expert Licensed User Longtime User Sep 10, 2015 #5 So, from a performance point of view, is it better to have very long IF's instead of chained IF's? Code: Copy If a and b and c and d and e and f and g and h then ... 'vs. If a then if b then if c then if d then ... end if end if end if end if Upvote 0
So, from a performance point of view, is it better to have very long IF's instead of chained IF's? Code: Copy If a and b and c and d and e and f and g and h then ... 'vs. If a then if b then if c then if d then ... end if end if end if end if
KMatle Expert Licensed User Longtime User Sep 10, 2015 #6 Usually ONE condition is enough to push a message and stop the action. What I do (to keep my code readable and my old head in line) is: If (Edittext1 is empty/wrong/too long) then ... RETURN -> Leaves the Sub End If If (Edittext2 is empty/wrong/too long) then ... RETURN ->Leaves the Sub End If Do the main thing here = It only will be executed if everything is OK Upvote 0
Usually ONE condition is enough to push a message and stop the action. What I do (to keep my code readable and my old head in line) is: If (Edittext1 is empty/wrong/too long) then ... RETURN -> Leaves the Sub End If If (Edittext2 is empty/wrong/too long) then ... RETURN ->Leaves the Sub End If Do the main thing here = It only will be executed if everything is OK