Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is This Statement Valid?

Status
Not open for further replies.

tridith

Programmer
Jul 22, 2005
39
CA
Code:
IIF("@Data.heading~" <= "22.4", "N", IIF("@Data.heading~" <= "67.4", "NE", IIF("@Data.heading~" <= "112.4", "E", IIF("@Data.heading~" <= "157.4", "SE", IIF("@Data.heading~" <= "202.4", "S", IIF("@Data.heading~" <= "247.4", "SW", IIF("@Data.heading~" <= "292.4", "W", IIF("@Data.heading~" <= "337.4", "NW", IIF("@Data.heading~" <= "360", "N", "")))))))))
 
Oh,

@Data.heading is a number that is suppose to be between 0 and 360
 
Is This Statement Valid?
No, as VBScript doesn't have an IIf function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
What could I do instead?
What do you want to do ? Where ? With what ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Well If what I originally posted isnt a valid statement, I want to do something that VBScript can do that would be valid following the same direction of my original post.
 
following the same direction of my original post
Sorry, I don't see any direction (apart NE, SW,... ;-))
I want to do something
Again, what do you want to do.
In other words, what is supposed to do your invalid statement and for which purpose ?

My guess:
you have a variable named heading containing a real value between 0.0 and 360.0
you want to populate a variable named, say, strDir.
One way:
Code:
If heading <= 22.4 Then
  strDir = "N"
ElseIf heading <= 67.4 Then
  strDir = "NE"
ElseIf heading <= 112.4 Then
  strDir = "E"
ElseIf heading <= 157.4 Then
  strDir = "SE"
ElseIf heading <= 202.4 Then
  strDir = "S"
ElseIf heading <= 247.4 Then
  strDir = "SW"
ElseIf heading <= 292.4 Then
  strDir = "W"
ElseIf heading <= 337.4 Then
  strDir = "NW"
ElseIf heading <= 360 Then
  strDir = "N"
Else
  strDir = ""
End If

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
BTW it's very easy write your own IIF function:
Code:
Function IIf(blnExpression, vTrueResult, vFalseResult)
  If blnExpression Then
    IIf = vTrueResult
  Else
    IIf = vFalseResult
  End If
End Function
But in this case, I would definitely go with PHV's suggestion, or look into the "Select Case" statement.
 
in select cases cant you only do equals? I need it to work with a range of numbers
 
in select cases cant you only do equals?
In VBScript, yes.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top