Select a Case Problem

I have this code:

For each c as char in "Hello World"
 Select Case c
  Case "h"
   DoSomething()
  Case "e"
   DoSomething()
  End Select
Next

Why can't I write like this:

Case "h" Or "e"
 DoSomething()

It says that "Long" values ​​cannot be converted to "Char"

How to complete this task?

+3
source share
4 answers

Using:

Select Case c
  Case "h"
  Case "e"
    DoSomething()
End Select

or

Select Case c
  Case "h","e"
    DoSomething()
End Select
+8
source
Case "h", "e"
   DoSomething()

if I remember my VB (which is doubtful)

The error message appears because it tries a bitwise "or" action between two lines, which seems pretty random.

+3
source
For each c as char in "Hello World"
    Select Case c.ToString 'When putting certain objects VB will true/false result of if the string is empty(false) or has text(true).
        Case "h", "E"
          DoSomething()
        Case "e", "H"
          DoSomethingElse()
    End Select
Next
+1

c, c - char, 'h' 'e' - . , select.
. Marek G.

0

All Articles