如果条件为多个值

Cho*_*Net -7 vb.net if-statement

我有一个下拉列表,其中我有0到9的值列表

如果所选值为1,2,3,4或5,则EmployeeName字段不能为空.

请帮我在vb.net中写这个条件.

提前致谢

Mat*_*lko 6

I think your best bet is to use a Select statement. This makes it easy to maintain your code if you change what each value does:

Select Case CInt(ComboBox.Value)

Case 1 To 5
    'Employee field cannot be blank
Case Else
    'Employee field can be blank
End Select
Run Code Online (Sandbox Code Playgroud)