VB6.0. 写出几种常用选择结构的语句格式

2025年03月23日 11:46
有2个网友回答
网友(1):

Private Sub Form_Load()
Dim i As Integer
i = 3

If i = 0 Then
    MsgBox "0"
ElseIf i = 1 Then
    MsgBox "1"
Else
    MsgBox "other"
End If

Select Case i
Case 0
    MsgBox "0"
Case 1
    MsgBox "1"
Case Else
    MsgBox "other"
End Select

MsgBox IIf(i = 0, "is 0", "not 0")

If i = 0 Then MsgBox "0"
End Sub

网友(2):

  1. If       Then

  2. If    

    Then

    (Else)

    End If

  3. Select Case 变量名

    Case Is

    Case a To b

    ...

    Case Else

    End Select

  4. IIf(条件,a,b)

    若条件为真则a,条件为假则b