VB Logical Error?

Discussion in 'OT Technology' started by SocialBrokerz, Feb 25, 2009.

  1. SocialBrokerz

    SocialBrokerz New Member

    Joined:
    Mar 14, 2006
    Messages:
    5,576
    Likes Received:
    0
    Location:
    in your interweb
    I have a select case for this security panel program that I am working on for class.

    here is my code.

    Select accessCode
    Case Is < 10
    message = "Call Security"
    Case 11 To 50
    message = "Technicians"
    Case 100, 999, 888, 777
    message = "Scientist"
    Case Else
    message = "Access denied"
    End Select

    logEntryListBox.Items.Insert(0, Date.Now & " " & message)

    the program layout looks like a standard telephone, press the appropriate numbers, and the result will show in a results textbox. just think of it as a real security panel

    everything works, however, if there is NO number(s) entered, it says "calling assistance" where as it should say "denied access."

    how can i fix this?
     
  2. mobbarley

    mobbarley Active Member

    Joined:
    Mar 4, 2005
    Messages:
    9,256
    Likes Received:
    2
    Location:
    Sydney
    don't have vb to test but a null might not cause it to hit the else, try checking for null first.
     
  3. 5Gen_Prelude

    5Gen_Prelude There might not be an "I" in the word "Team", but

    Joined:
    Mar 14, 2000
    Messages:
    14,519
    Likes Received:
    1
    Location:
    Vancouver, BC, CANADA
    Access code = 0 which is why the first one fires. So change it to 1 to 9 and it should work.

    But your question needs work - you're telling me what it should do and what it is doing and neither of those things are true based on the code you provided - you didn't use the exact phrase your code was using which confused me at first.
     

Share This Page