|
-
Jan 11th, 2002, 05:28 PM
#1
Thread Starter
Frenzied Member
?? Select Case True ??
somebody recently told me that Select Case True is valid syntax and can be used as in the following.
Code:
Public Function Latitude(Y As Double, X As Double) As Double
'Function returns Radians in range -Pi/2 to Pi/2 (-90 to 90 degrees)
'Quandrant assumed to be determined by sign of Y.
'X assumed to be positive. Abs Function used to force positive value.
'Hpi = Pi/2 Qpi = Pi/4 (90 & 45 degrees)
Select Case True
Case Abs(X) > Abs(Y)
Latitude = Atn(Y / Abs(X))
Case Abs(X) < Abs(Y)
Latitude = Hpi - Atn(Abs(X) / Y)
Case X = 0
Latitude = 0
Case Else
Latitude = Qpi '45 degrees
End If
End Function
I am going to try it. Does anybody know if this is going to work?
It looks cleaner that ElseIf constructs.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
-
Jan 11th, 2002, 05:39 PM
#2
Frenzied Member
What happens if more than one condition is met?
seoptimizer2001
VB 6.0, VC++, VI, ASP, JavaScript, HTML,
Perl, XML, SQL Server 2000
If God had intended us to drink beer, He would have given us stomachs.
Please use the [code] and [vbcode] tags in your posts!
If you don't know how to use them please go HERE!

-
Jan 11th, 2002, 05:41 PM
#3
somebody recently told me that Select Case True is valid syntax and can be used as in the following.
That statement is correct.
An example:
VB Code:
Private Sub Command1_Click()
Select Case True
Case 9 < 5
Print "one"
Case 5 < 9
Print "two"
End Select
End Sub
Or
VB Code:
Private Sub Command1_Click()
Dim a As Boolean, b As Boolean
b = True
Select Case True
Case a
Print "one"
Case b
Print "two"
End Select
End Sub
________
Extreme q vaporizer
Last edited by Bruce Fox; Aug 14th, 2011 at 04:06 AM.
-
Jan 11th, 2002, 05:56 PM
#4
Originally posted by seoptimizer2001
What happens if more than one condition is met?
Then only the first condition that is met will be executed.
-
Jan 11th, 2002, 08:12 PM
#5
Thread Starter
Frenzied Member
Bruce Fox: Thanx for your reply. If I discover otherwise, I will post again. Meanwhile, I assume that two bright people cannot be wrong when they agree.
It will be a while before I actually try it.
Live long & prosper.
The Dinosaur from prehistoric era prior to computers.
Eschew obfuscation!
If a billion people believe a foolish idea, it is still a foolish idea!
VB.net 2010 Express
64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|