|
-
Apr 12th, 2004, 07:05 PM
#1
Thread Starter
Lively Member
Checking if a variable has been dimmed?
If i have an if statement, for example:
VB Code:
If x = 1 then
Static bob as String = "hello"
ElseIf
Static joe as String = "hello2"
Else
Static mike as String = "hello3"
how would i check which ones it had done if i had a different value for x three times. like, x was 1,1,and 3, so joe would never be static'ed. how would i check to see if bob was static'ed, joe was static'ed, and mike was static'ed?
-
Apr 12th, 2004, 11:56 PM
#2
Sleep mode
It doesn't make sense . Why would you do that ?
-
Apr 13th, 2004, 04:20 AM
#3
PowerPoster
Hi Pirate,
"It doesn't make sense . Why would you do that ?"
One reason would be if any, either or all of Bob Joe & Mike (working from different computors) were being allowed access to data etc and Synth3tic was checking for which password to compare.
Hi Synth3tic,
I am probably pointing out the obvious but your code should be
VB Code:
If x = 1 then
Static bob as String = "hello"
ElseIf x=2 then
Static joe as String = "hello2"
Else
Static mike as String = "hello3"
I don't know about checking the scope of the declaration but you can check if they have been filled
To check which has been declared, one way would be:
VB Code:
Dim Bob As String = "Hello"
Dim Joe As String = ""
Dim Mike As String = ""
Dim iCount As Integer = 1
Dim oCheck As Object
Dim strCheck As String
Dim StrName As String
For iCount = 1 To 3
Select Case iCount
Case Is = 1
StrName = "Bob"
oCheck = Bob
Case Is = 2
StrName = "Joe"
oCheck = Joe
Case Is = 3
StrName = "Mike"
oCheck = Mike
End Select
If Len(oCheck) > 1 Then
strCheck = " IS declared"
Else
strCheck = " is NOT declared"
End If
MessageBox.Show(StrName & strCheck)
Next iCount
Taxes
The more I learn about VB.NET the more I like dBaseIII Plus
The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.
-
Apr 13th, 2004, 12:34 PM
#4
Sleep mode
Originally posted by Synth3t1c
how would i check to see if bob was static'ed, joe was static'ed, and mike was static'ed?
This is what I referred to ! I'm sure it's one of those bad programming techniques .
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
|