如果然后基本

时间:2017-03-15 18:09:28

标签: excel-vba vba excel

我是VBA的新手,我想测试一个基本的If和Then语句。我想创建一条消息,根据excel命名分数中单元格A1中的数据说“是”或“否”。我尝试了很多东西,有时候只是弹出所有的消息,所以想知道如何正确地写这个?

以下是实际陈述:

Sub IfTest()    
Dim Score As Integer    
Dim Msgbox As String

Score = Cells(1, 1).Value

If Score = 1 Then    
    Msgbox = "Yes"
Else    
    Msgbox = "no"
End If    

End Sub

1 个答案:

答案 0 :(得分:2)

欢迎来到VBA!

while mort == True:
    #.................
active_sprite_list.update()
current_level.update()
print(mort)
>>>False

在逗号之间插入按钮样式。 按钮样式和标题是可选的。

因此,对于您的示例,请删除" ="'然后执行:

MsgBox "This is my message", , "This is my Title"

查看MS链接:MsgBox Function

* **按comintern评论编辑 - 删除此行 !!!!!!

If Score = 1 Then
    Msgbox "Yes"
Else
    Msgbox "no"
End If