Case with more options

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marcolino

    #1

    Case with more options

    Hi,
    I have a particular need and I tryed to use this code:

    Select Case i
    Case 1 or 100
    Istructions 1
    Case 2 or 100
    Istructions 2
    Case 3 or 100
    Istructions 3
    End Select

    In deep I need that:
    if i=1 or 2 or 3 i need to execute the single instruction contained in
    a single case.
    If i=100 i need to execute all instruction.
    This code does not work, any suggestions?

    Thanks
  • vovan

    #2
    Re: Case with more options

    How about this:
    Select Case i
    Case 1
    Istructions 1
    Case 2
    Istructions 2
    Case 3
    Istructions 3
    Case 100
    Istructions 1
    Istructions 2
    Istructions 3
    End Select
    ?

    vovan

    "Marcolino" <marco.pozzuolo @gmail.comwrote in message
    news:35490945-7db5-4e6a-874a-9fb2f23ebfd9@59 g2000hsb.google groups.com...
    Hi,
    I have a particular need and I tryed to use this code:
    >
    Select Case i
    Case 1 or 100
    Istructions 1
    Case 2 or 100
    Istructions 2
    Case 3 or 100
    Istructions 3
    End Select
    >
    In deep I need that:
    if i=1 or 2 or 3 i need to execute the single instruction contained in
    a single case.
    If i=100 i need to execute all instruction.
    This code does not work, any suggestions?
    >
    Thanks

    Comment

    • Martin H.

      #3
      Re: Case with more options

      Hi,

      it would be more like this:

      Rather than using Select Case, I would use 3 If...Then statements.

      If i = 1 OrElse i = 100 Then
      Instructions 1
      End If

      If i = 2 OrElse i = 100 Then
      Instructions 2
      End If

      If i = 3 OrElse i = 100 Then
      Instructions 3
      End If

      On 17.03.2008 20:56, vovan wrote:
      How about this:
      Select Case i
      Case 1
      Istructions 1
      Case 2
      Istructions 2
      Case 3
      Istructions 3
      Case 100
      Istructions 1
      Istructions 2
      Istructions 3
      End Select
      ?
      >
      vovan
      >
      "Marcolino" <marco.pozzuolo @gmail.comwrote in message
      news:35490945-7db5-4e6a-874a-9fb2f23ebfd9@59 g2000hsb.google groups.com...
      >Hi,
      >I have a particular need and I tryed to use this code:
      >>
      >Select Case i
      > Case 1 or 100
      > Istructions 1
      > Case 2 or 100
      > Istructions 2
      > Case 3 or 100
      > Istructions 3
      >End Select
      >>
      >In deep I need that:
      >if i=1 or 2 or 3 i need to execute the single instruction contained in
      >a single case.
      >If i=100 i need to execute all instruction.
      >This code does not work, any suggestions?
      >>
      >Thanks
      >
      >

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: Case with more options

        "Marcolino" <marco.pozzuolo @gmail.comschri eb:
        Select Case i
        Case 1 or 100
        Istructions 1
        Case 2 or 100
        Istructions 2
        Case 3 or 100
        Istructions 3
        End Select
        >
        In deep I need that:
        if i=1 or 2 or 3 i need to execute the single instruction contained in
        a single case.
        If i=100 i need to execute all instruction.
        This code does not work, any suggestions?
        \\\
        Select Case i
        Case 1, 2, 3
        Instructions
        Case 100
        Instructions
        End Select
        ///

        --
        M S Herfried K. Wagner
        M V P <URL:http://dotnet.mvps.org/>
        V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

        Comment

        • Cor Ligthert[MVP]

          #5
          Re: Case with more options

          Herfried,

          I had expected more from you

          :-)

          I would go for the three if's or easier the case where the one for 100 was
          including a method to do instructions 1, 2 and 3

          Cor

          Comment

          Working...