Understanding what response codes come back from MsgBox

前端 未结 8 1799
春和景丽
春和景丽 2021-02-19 08:32

I\'m very new to programming and I\'m just starting to learn VBA with excel. I came across on this website and did the examples here but I have question about this code:

<
8条回答
  •  悲哀的现实
    2021-02-19 09:18

    Just rewrite to the equivalent:

    Private Sub CommandButton1_Click()
      Dim optionSelected As VbMsgBoxResult
      optionSelected = MsgBox("Click Yes to Proceed, No to stop", vbYesNoCancel, "Login")
      If optionSelected = vbYes Then
        Range("A1").Value = "You may proceed"
        ActiveWorkbook.Activate 
      ElseIf optionSelected = vbNo Then
        ActiveWorkbook.Close
      End If
    End Sub
    

    And move on

自定义标题
段落格式
字体
字号
代码语言
提交回复
热议问题