Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

Using a Variable in a VBA Message Box


TechKnowledge Content

Question:

Can a variable be used in a VBA message box?


Answer:

Yes, a variable can be used in a VBA message box. Below is an example of using a variable in a message box.


Private Sub Field_BeforeLostFocus(KeepFocus As Boolean, CancelLogic As Boolean)


Dim Var1 As String


Var1 = VendorID

MsgBox "The variable is " + Var1


End Sub


In this example, the VendorID from the window is being set as the variable. The variable is being called Var1. When the message box is displayed, the message will read "The variable is XXXX" where XXXX is the VendorID from the window. If ACETRAVE0001 was the vendor on the window, the message box would read "The variable is ACETRAVE0001".




This article was TechKnowledge Document ID:24404

↑ Back to the top


Keywords: kbmbspartner, kbmbsmigrate, kb

↑ Back to the top

Article Info
Article ID : 855685
Revision : 1
Created on : 1/7/2017
Published on : 6/30/2012
Exists online : False
Views : 72