Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: None  |  size: 1.68 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Tidying a complicated if-else statement
  2. If cint(QtyShop) > 0 Then
  3.                             msg = "Stock found in this shop"
  4.                         ElseIf cint(QtyAllShops) > 0 Then
  5.                             msg = "Stock found in a different shop"
  6.                         Else
  7.                             msg= "No stock found anywhere"
  8.                         End If
  9.        
  10. If IsNumeric(QtyShop) Then
  11.                             If cint(QtyShop) > 0 Then
  12.                                 msg = "Stock found in this shop"
  13.                             ElseIf IsNumeric(QtyAllShops) Then
  14.                                 If cint(QtyAllShops) > 0 Then
  15.                                     msg = "Stock found in a different shop"
  16.                                 Else
  17.                                     msg = "No stock found anywhere"
  18.                                 End If
  19.                             Else
  20.                                 msg = "No stock found anywhere"
  21.                             End If
  22.                         Else
  23.                             If IsNumeric(QtyAllShops) Then
  24.                                 If cint(QtyAllShops) > 0 Then
  25.                                     msg = "Stock found in a different shop"
  26.                                 Else
  27.                                     msg = "No stock found anywhere"
  28.                                 End If
  29.                             Else
  30.                                 msg = "No stock found anywhere"
  31.                             End If
  32.                         End If
  33.        
  34. ' Input validation ….
  35.  
  36. If QtyShop > 0 Then Return "Stock found in this shop"
  37.  
  38. If QtyAllShops > 0 Then Return "Stock found in a different shop"
  39.  
  40. Return "No stock found anywhere"