Results 1 to 4 of 4

Thread: Help with Case statements [RESOLVED]

  1. #1

    Thread Starter
    Addicted Member DKasler's Avatar
    Join Date
    Jan 2005
    Location
    Brooklyn, NYC
    Posts
    177

    Resolved Help with Case statements [RESOLVED]

    I am trying to dbl_click on a Treeview and have it work kind of like a menu, Its doing what its supposed to upto the Case statement.

    My thought was to use the case statment to do things like open forms, etc... but it doesnt seem to work as I thought.

    Is this an inappropriate use of Case? or am I just not coding it correctly?

    VB Code:
    1. Dim Selected
    2. Dim tempArray() As String
    3.  
    4. tempArray = Split(TreeView1.SelectedItem.Text, " ") 'remove the space and store each word in an array
    5. Selected = Join(tempArray, "") 'join back together again
    6.  
    7. Select Case Selected
    8.    
    9. Case NewPatient
    10.     FrameNewPatient.visible = true
    11.    
    12. Case EditPatien
    13.     MsgBox "NO"
    14. End Sub

    What I thought was that since Select Case is selecting my Selected variable

    Then of the Selected happens to be = to NewPatient

    that Case NewPatient would be triggerd and the code under it.
    Last edited by DKasler; Feb 8th, 2005 at 01:34 PM. Reason: Issue Resolved
    -----MY SITES-----
    BayRidgeNights.Com - NYC Nightlife Forums

    Fight Communism - Rate Posts!

  2. #2
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Re: Help with Case statements

    Try adding quotes:

    VB Code:
    1. Case "NewPatient"
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  3. #3
    Addicted Member Max_aka_NOBODY's Avatar
    Join Date
    Jul 2004
    Location
    Amman, Jordan
    Posts
    179

    Re: Help with Case statements

    If I'm getting you correctly, you're trying to check the contents of a string. You need to enclose NewPatient and EditPatient in quotes, like this: "NewPatient", "EditPatient". I don't understand why would you want to remove the spaces either. BTW, you need a "End Select" after the whole statement.

  4. #4

    Thread Starter
    Addicted Member DKasler's Avatar
    Join Date
    Jan 2005
    Location
    Brooklyn, NYC
    Posts
    177

    Re: Help with Case statements

    Thank you both.

    Adding quotes as you suggested fixed my problem.

    As for the question about striping the spaces, that was something I was toying with before I tried the whole case statement idea, and I just removed it.

    Thanks guys.
    -----MY SITES-----
    BayRidgeNights.Com - NYC Nightlife Forums

    Fight Communism - Rate Posts!

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