【前言】
今天整理桌面发现好几个没发的博客,哈哈哈,现在发了吧,不然又不知道拖到什么时候了,之前一直用Word来保存我的草稿博客,现在用OneNote,希望会使我用的更加得心应手吧。
【正文】
elseif
是在前面的条件不成立的情况下,进行新的判断的时候用的
举个栗子:
if 性别="女" then
…………
elseif 年龄<20 then
…………
else
…………
endif
这里对女性做一种处理;对不是女性(即男性)中小于20岁的做一种处理;对其余的(男性,大于等于20岁的)做第三种处理
举个栗子:Private Sub nested_if_demo_Click()
Dim a As Integer
a = 23
If a > 0 Then
MsgBox "The Number is a POSITIVE Number"
If a = 1 Then
MsgBox "The Number is Neither Prime NOR Composite"
ElseIf a = 2 Then
MsgBox "The Number is the Only Even Prime Number"
ElseIf a = 3 Then
MsgBox "The Number is the Least Odd Prime Number"
Else
MsgBox "The Number is NOT 0,1,2 or 3"
End If
ElseIf a < 0 Then
MsgBox "The Number is a NEGATIVE Number"
Else
MsgBox "The Number is ZERO"
End If
End Sub
---------(*^▽^*)--------------(#^.^#)-------------O(∩_∩)O--------------
Else
举个栗子:
Private Sub if_demo_Click()
Dim x As Integer
Dim y As Integer
x = 234
y = 324
If x > y Then
MsgBox "X is Greater than Y"
Else
Msgbox "Y is Greater than X"
End If
End Sub
【后记】
下回可不能忘记上传博客了,都辛辛苦苦的写完了