Re: Switch on Strings

On Sat, 14 Jan 2006 00:32:18 GMT, fb <fb@xxxxxxxxx> wrote, quoted or
indirectly quoted someone who said :

>myColor is a String being read in from an HTML file PARAM line.
>The above code doesn't work, because switch doesn't work with strings.
>So I was wondering how else I can do this...

you do it with enums. See

You convert your switch string to an enum with valueOf and use enum
constants instead of strings on your case labels.
Canadian Mind Products, Roedy Green. Java custom programming, consulting and coaching.

Relevant Pages

  • Re: Reflection and variable selection? Late binding?
    ... If your variables are all integers (or any of the supported base Types for Enums) then use an Enum as in my second example. ... If your variables are other Types such as strings or complex Types then you should use the switch statement. ... when each case is doing something very similar: going from string "x" to ...
  • Re: Change Text to Memo
    ... Switch a given table field to Memo ... Function SwitchFieldType(sDb As String, sTableName As String, sFieldName ... Dim sSQL As String ... If Err.Number = 0 Then Exit Function ...
  • Re: proposal: reswitch
    ... > which levels of loops and/or switches and/or ... socket -server command ?-myaddr addr? ... You've got the quick-exit (break, no string), the fall-through to next ... -switch option), then it'd be the nth switch. ...
  • RE: Have some problem with enum and string
    ... I have below a for loop and a switch in the for loop. ... I have also a enum called colBlowStep with some values. ... I know I can use string but I rather want to use enum. ...
  • Re: SRV
    ... I also play .12s for jazz, and can't bend those well at all. ... little as far as bending until you go to a wound string. ... When I switch from 10's to 9's, the 9's feel like limp rubber ...