else与elseif

【前言】       

       今天整理桌面发现好几个没发的博客,哈哈哈,现在发了吧,不然又不知道拖到什么时候了,之前一直用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

【后记】

下回可不能忘记上传博客了,都辛辛苦苦的写完了可怜

评论 24
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值