Mr_LinDowsMac
Mr_LinDowsMac

Reputation: 2702

Select Case with Chars with Option Strict On

After setting on the option strict i get syntax errors in the following:

Select Case Me.oWorker.Relationship_Status
    Case "S"
        Me.opSingle.Checked = True
    Case "C"
        Me.opMarried.Checked = True
    Case "O"
        Me.opAnotherStatus.Checked = True
End Select

Compiler says that the option strict disallows implicit conversions fro String to Char. That Relationship_Status property of oWorker object is a Char of course.

How can I workaround this without changing the Relationship_status property to String? Do I really need to use CChar to Cast like this: CChar("S") ?

Upvotes: 0

Views: 810

Answers (1)

charles-allen
charles-allen

Reputation: 4081

Add a c after. This is the VB char syntax:

Select Case Me.oWorker.Relationship_Status 
    Case "S"c
        Me.opSingle.Checked = True 
    Case "C"c
        Me.opMarried.Checked = True 
    Case "O"c
        Me.opAnotherStatus.Checked = True
End Select

Upvotes: 1

Related Questions