Sei sulla pagina 1di 1

18

Table 3.2: Returned Values and Command Buttons

Value Named Constant Button Clicked


1 vbOk Ok button
2 vbCancel Cancel button
3 vbAbort Abort button
4 vbRetry Retry button
5 vbIgnore Ignore button
6 vbYes Yes button
7 vbNo No button

Example 3.1
In this example, the message in cell (1,2) “Your first VBA program” will be displayed
in the message box. As no named constant is added, the message will simply display
the message and the “OK” button, as shown in Figure 3.1

Private Sub CommandButton1_Click()

Dim YourMsg As String

Cells(1, 2) = "Your first VBA program"

YourMsg = Cells(1, 2)

MsgBox YourMsg

End Sub

Potrebbero piacerti anche