Results 1 to 7 of 7

Thread: Casewhere I don't understand this...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Red face Casewhere I don't understand this...

    OK, its time for another noobish question, and its about Casewhere structures. Now back in VB6 I managed to get a casewhere structure working successfully, but by now I don't know how.

    My Problem: I have a Combo Box on my form with a Collection of around 380 objects. I need to store specific variables under each selection in the Collection and I feel that casewhere is better than:

    VB Code:
    1. If cboObject.WhateverItemSelected = True Then
    2.     Do This
    3. Else If cboObject.WhateverItemSelected = True Do This
    4. Else If cboObject.WhateverItemSelected = True Do This
    5. Else If cboObject.WhateverItemSelected = True Do This
    6. 'And this goes on for all objects
    7. End If

    So basically, casewhere would be better right? I could make a DB but I only have FileMaker and I haven't the slightest clue on how to implement a DB made in FM into a program. I'm not even at that level yet in VB.NET book! So anyway, How do I make a casewhere Thanks...
    Last edited by martw; May 6th, 2005 at 10:27 PM. Reason: Slight Error.

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Casewhere I don't understand this...

    VB Code:
    1. Select Case Me.ComboBox1.SelectedIndex
    2.             Case 1
    3.                 'do your stuff
    4.                 Exit Select
    5.             Case 2
    6.                 'do your stuff
    7.                 Exit Select
    8.         End Select

  3. #3
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Casewhere I don't understand this...

    Dont forget the Case Else
    VB Code:
    1. Select Case Me.ComboBox1.SelectedIndex
    2.     Case 1
    3.         'do your stuff
    4.     Case 2
    5.         'do your stuff
    6.     Case Else
    7.         'when all other options are not matched
    8. End Select
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Casewhere I don't understand this...

    Dude, that little animation in your sig is awesome

    So basically, I HAVE to use Case 1, Case 2, Case 3 for all of my 380 or so entries in the collection? Why can't I use the text of the entry selected?

  5. #5
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    Re: Casewhere I don't understand this...

    you can still use the text you select in your combobox
    VB Code:
    1. select case combobox1.selecteditem
    2. 'blah blah..
    3. end case

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Casewhere I don't understand this...

    You can also use a range...
    VB Code:
    1. Select Case Me.ComboBox1.SelectedIndex
    2.     Case 1 To 100
    3.         'do your stuff
    4.     Case 101 To 200
    5.         'do your stuff
    6.     Case Else
    7.         'when all other options are not matched
    8. End Select
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Mar 2005
    Posts
    124

    Re: Casewhere I don't understand this...

    Thanks that helped

    Man, that little fighting guy is awesome!... Why doesn't he try the door knob?

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