Understanding automation : How is automation coding structured? : Providing message boxes and input boxes |
In VBA, you can present simple messages to the user by using the MsgBox
function:
Dim retval As Long |
retval = MsgBox("Click OK if you agree.", _ |
vbOKCancel, "Easy Message") |
If retval = vbOK Then |
MsgBox "You clicked OK.", vbOK, "Affirmative" |
End If |
You can also get strings from the user by using InputBox
function:
Dim inText As String
inText = InputBox("Input some text:", "type here")
If Len(inText) > 0 Then
MsgBox "You typed the following: " & inText & "."
End If
If the user clicks Cancel, the length of the string returned in inText
is zero.
• |
For information on creating more complex user interfaces, see Making macros user-friendly.
|
Copyright 2013 Corel Corporation. All rights reserved.