I have been trying to execute a VB script using the "If.. then" condition. This is what I have to display.
I have to show 3 messages: one for highest number, second is for lowest number, and third will show a message "The numbers are the same"(if they are all equal). I need to get the three pop ups to appear one by one.
I have tried this:
Option explicit
Dim Gn, Sn, En
Gn= inputbox("enter first number")
Sn= inputbox("enter second number")
En =inputbox("enter third number")
If ((Gn > Sn) AND (Gn > En)) then
Msgbox ("The Highest Number Is =" & Gn)
End if
If ((En =Gn) AND (En =Sn)) then
Msgbox ("The Numbers Are Equal =" & En)
End if
If ((Sn<Gn) AND (Sn <En))then
Msgbox ("The Lowest Number Is =" & Sn)
End If
This code executes successfully if the value of the first variable satisfies all the conditions, but there's still a problem. It does not show the three messages one by one. For example, if Gn > En and Sn, then it runs successfully.
There's an alternative way, but it's too much lengthy and complex.
Option explicit
Dim Gn, Sn, En
Gn= inputbox("enter first number")
Sn= inputbox("enter second number")
En =inputbox("enter third number")
If ((Gn > Sn) AND(Sn > En ) AND (Gn > En)) then
Msgbox ("Greatest number is = " & Gn & "Smallest number is = " & Sn & "The numbers are not equal" )
end if
I will have to try all permutations and combinations to get the above one to work.
Please help!
Aucun commentaire:
Enregistrer un commentaire