Results 1 to 4 of 4

Thread: Checking if a variable has been dimmed?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2003
    Posts
    91

    Checking if a variable has been dimmed?

    If i have an if statement, for example:

    VB Code:
    1. If x = 1 then
    2. Static bob as String = "hello"
    3. ElseIf
    4. Static joe as String = "hello2"
    5. Else
    6. 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?

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    It doesn't make sense . Why would you do that ?

  3. #3
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949
    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:
    1. If x = 1 then
    2. Static bob as String = "hello"
    3. ElseIf x=2 then
    4. Static joe as String = "hello2"
    5. Else
    6. 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:
    1. Dim Bob As String = "Hello"
    2.         Dim Joe As String = ""
    3.         Dim Mike As String = ""
    4.  
    5.  
    6.         Dim iCount As Integer = 1
    7.         Dim oCheck As Object
    8.         Dim strCheck As String
    9.         Dim StrName As String
    10.         For iCount = 1 To 3
    11.             Select Case iCount
    12.                 Case Is = 1
    13.                     StrName = "Bob"
    14.                     oCheck = Bob
    15.                 Case Is = 2
    16.                     StrName = "Joe"
    17.                     oCheck = Joe
    18.                 Case Is = 3
    19.                     StrName = "Mike"
    20.                     oCheck = Mike
    21.             End Select
    22.             If Len(oCheck) > 1 Then
    23.                 strCheck = " IS declared"
    24.             Else
    25.                 strCheck = " is NOT declared"
    26.             End If
    27.             MessageBox.Show(StrName & strCheck)
    28.         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.

  4. #4
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    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
  •  



Click Here to Expand Forum to Full Width