私は以下を試しました:
Select Case Combo1.SelectedItem Or Combo2.SelectedItem
しかし、私はエラーが発生します:
Conversion from String "string here" to type 'Long' is not valid
複数の選択ケースを持つことは可能ですか?
私は以下を試しました:
Select Case Combo1.SelectedItem Or Combo2.SelectedItem
しかし、私はエラーが発生します:
Conversion from String "string here" to type 'Long' is not valid
複数の選択ケースを持つことは可能ですか?
コンマを使用して複数の値を区切ります。
Case Combo1.SelectedItem, Combo2.SelectedItem
を使用Orすると、 の値と比較する前に評価される式になりますSelect。
の値が値の場合Select、Longコントロールから文字列を変換する必要がある場合があります。
Case CLng(Combo1.SelectedItem), CLng(Combo2.SelectedItem)
質問に直接対処するには、select で複数の値をテスト式として使用することはできません。
Select Case v1, v2 'Not possible
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Dim i, j As Integer
Dim value As Integer
For i = 1 To 3
For j = 1 To 5
value = (GetCode(i, j))
TextBox1.Text = TextBox1.Text & "i=" & i & "->j=" & j & "=" & value & vbCrLf
Next
Next
End Sub
Function GetCode(ByVal v1 As Integer, ByVal v2 As Integer) As Integer
Dim retval As Integer
Dim forselect As String
forselect = v1 & v2
Select Case forselect
Case 11
retval = 11
Case 12
retval = 12
Case 13
retval = 13
Case 14
retval = 14
Case 15
retval = 15
Case 21
retval = 21
Case 22
retval = 22
Case 23
retval = 23
Case 24
retval = 24
Case 25
retval = 25
Case 31
retval = 31
Case 32
retval = 32
Case 3, 3
retval = 33
Case 34
retval = 34
Case 35
retval = 35
End Select
Return retval
End Function