case statements

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kronecker@yahoo.co.uk

    case statements

    Is there any way to make case statements case independent?

    ie
    Case Is = "dim the light"
    or
    Case Is = "Dim the light"

    making them the same outcome without putting every possibility. eg

    Case Is = "dim The light" as well

    K.
  • Lloyd Sheen

    #2
    Re: case statements

    kronecker@yahoo .co.uk wrote:
    Is there any way to make case statements case independent?
    >
    ie
    Case Is = "dim the light"
    or
    Case Is = "Dim the light"
    >
    making them the same outcome without putting every possibility. eg
    >
    Case Is = "dim The light" as well
    >
    K.

    Supposing that your present code looks something like:

    Select Case AStringVariable
    Case "dim the light"
    ....

    Change it to
    Select Case AStringVariable .toUpper (or toLower)
    Case "DIM THE LIGHT" (or "dim the light")

    Hope this helps
    LS

    Comment

    • kronecker@yahoo.co.uk

      #3
      Re: case statements

      On Aug 8, 11:35 am, Lloyd Sheen <a...@b.cwrot e:
      kronec...@yahoo .co.uk wrote:
      Is there any way to make case statements case independent?
      >
      ie
      Case Is = "dim the light"
      or
      Case Is = "Dim the light"
      >
      making them the same outcome without putting every possibility. eg
      >
      Case Is = "dim The light" as well
      >
      K.
      >
      Supposing that your present code looks something like:
      >
      Select Case AStringVariable
      Case "dim the light"
      ...
      >
      Change it to
      Select Case AStringVariable .toUpper (or toLower)
      Case "DIM THE LIGHT" (or "dim the light")
      >
      Hope this helps
      LS
      Is there no way to switch of case dependency all together since there
      may well be loads of possibilities. It comes from speech recognition?

      K.

      Comment

      • Herfried K. Wagner [MVP]

        #4
        Re: case statements

        <kronecker@yaho o.co.ukschrieb:
        Is there any way to make case statements case independent?
        >
        ie
        Case Is = "dim the light"
        or
        Case Is = "Dim the light"
        >
        making them the same outcome without putting every possibility. eg
        >
        Case Is = "dim The light" as well
        The result depends on the setting of 'Option Compare'. If it is set to
        'Text', the first branch in the sample below will be executed, if not, the
        second branch will be called:

        \\\
        Select Case "FOO"
        Case "foo"
        MsgBox("foo")
        Case "FOO"
        MsgBox("FOO")
        End Select
        ///

        If you want to make the compare option independent from 'Option Compare',
        you can use the code below:

        \\\
        Const Value As String = "FOO"
        Const CompareMethod As CompareMethod = CompareMethod.B inary
        Select Case True
        Case StrComp(Value, "foo", CompareMethod) = 0
        MsgBox("foo")
        Case StrComp(Value, "FOO", CompareMethod) = 0
        MsgBox("FOO")
        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

        • Steve Gerrard

          #5
          Re: case statements

          kronecker@yahoo .co.uk wrote:
          >Change it to
          >Select Case AStringVariable .toUpper (or toLower)
          >Case "DIM THE LIGHT" (or "dim the light")
          >>
          >Hope this helps
          >LS
          >
          Is there no way to switch of case dependency all together since there
          may well be loads of possibilities. It comes from speech recognition?
          >
          I think you missed that if you make the case variable upper, and specify all
          uppercase cases, then the case of the original doesn't matter.

          Dim S As String

          S = "Foo"
          ' or
          S = "fOo"
          ' or
          S = "fOO"
          ' or
          S = "FoO"

          Case S.ToUpper
          Case "FOO"
          ' all get here


          Comment

          • kronecker@yahoo.co.uk

            #6
            Re: case statements

            On Aug 8, 1:12 pm, "Steve Gerrard" <mynameh...@com cast.netwrote:
            kronec...@yahoo .co.uk wrote:
            Change it to
            Select Case AStringVariable .toUpper (or toLower)
            Case "DIM THE LIGHT" (or "dim the light")
            >
            Hope this helps
            LS
            >
            Is there no way to switch of case dependency all together since there
            may well be loads of possibilities. It comes from speech recognition?
            >
            I think you missed that if you make the case variable upper, and specify all
            uppercase cases, then the case of the original doesn't matter.
            >
            Dim S As String
            >
            S = "Foo"
            ' or
            S = "fOo"
            ' or
            S = "fOO"
            ' or
            S = "FoO"
            >
            Case S.ToUpper
            Case "FOO"
            ' all get here
            I don't have an original though since it comes from a recognition
            engine for speech.

            K.

            Comment

            • Steve Gerrard

              #7
              Re: case statements

              kronecker@yahoo .co.uk wrote:
              >>
              >I think you missed that if you make the case variable upper, and
              >specify all uppercase cases, then the case of the original doesn't
              >matter.
              >>
              >Dim S As String
              >>
              >S = "Foo"
              >' or
              >S = "fOo"
              >' or
              >S = "fOO"
              >' or
              >S = "FoO"
              >>
              >Case S.ToUpper
              > Case "FOO"
              > ' all get here
              >
              I don't have an original though since it comes from a recognition
              engine for speech.
              >
              What comes after the words Select Case in your code?


              Comment

              Working...