Results 1 to 5 of 5

Thread: Easy Select Case question.......

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    Easy Select Case question.......

    I have a control array with 2 option buttons. Here's what I need to do:

    If the index is 0 then I need to do such-and-such, and if the index is anything else, I need to do something different. I HAVE to use a select case statement for this.

    VB Code:
    1. Select Case optLookup
    2.  
    3. Case1  'Index of the optlookup is 0
    4.  
    5. Case Else
    6. 'do something else here
    7. End Select

    Am I even close? I need to check the index to determine which option button in the control array is selected. Any help appreciated.

  2. #2
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Depends on where you ar eputting this code. Is it going into the option click event?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2001
    Location
    Maumelle, AR
    Posts
    624

    yep.....

    in the option click event

  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687
    When do you need to do the checking? When the option button is clicked? Or later (like a command button being clicked?).....

    VB Code:
    1. Private Sub optLookup_Click(Index as Integer)
    2.   Select Case Index
    3.     Case 0
    4.        'Do something here
    5.     Case Else
    6.       'Do that other thing
    7.   End Select
    8. End Sub

    ... or ...

    VB Code:
    1. Private mintLookup As Integer
    2.  
    3. Private Sub optLookup_Click(Index as Integer)
    4.   mintLookup = Index
    5. End Sub
    6.  
    7. Private Sub cmdDoSomething_Click()
    8.   Select Case mintLookup
    9.     Case 0
    10.        'Do something here
    11.     Case Else
    12.       'Do that other thing
    13.   End Select
    14. End Sub
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    techgnome's got what you need with his first snippett then.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

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