
Untitled
By: a guest on
Jun 21st, 2012 | syntax:
None | size: 1.68 KB | hits: 13 | expires: Never
Tidying a complicated if-else statement
If cint(QtyShop) > 0 Then
msg = "Stock found in this shop"
ElseIf cint(QtyAllShops) > 0 Then
msg = "Stock found in a different shop"
Else
msg= "No stock found anywhere"
End If
If IsNumeric(QtyShop) Then
If cint(QtyShop) > 0 Then
msg = "Stock found in this shop"
ElseIf IsNumeric(QtyAllShops) Then
If cint(QtyAllShops) > 0 Then
msg = "Stock found in a different shop"
Else
msg = "No stock found anywhere"
End If
Else
msg = "No stock found anywhere"
End If
Else
If IsNumeric(QtyAllShops) Then
If cint(QtyAllShops) > 0 Then
msg = "Stock found in a different shop"
Else
msg = "No stock found anywhere"
End If
Else
msg = "No stock found anywhere"
End If
End If
' Input validation ….
If QtyShop > 0 Then Return "Stock found in this shop"
If QtyAllShops > 0 Then Return "Stock found in a different shop"
Return "No stock found anywhere"