I want a MessageBox
to display an int
variable, can anybody help?
with VBA, follow these steps: Create a message box with the MsgBox function (MsgBox(…)). Specify the buttons to be displayed in the message box (Buttons:=ButtonsExpression). Assign the value returned by the MsgBox function to a variable (Variable = MsgBox(…)).
In the VBA editor go to the View menu and click on Locals Window. Each time F8 is pressed one line of VBA is executed. When the range MyRange is set, you can see that values appear for it in the Locals window. By examining the MyRange object you can drill down to see the values in it.
Expand the contents of the workbook and right click on Microsoft Excel Objects. Hover your cursor over Insert and select Module from the menu that appears. This will create a new blank module. Now we can start creating our first message box.
You want to use the MessageBox.Show() method
int num = 0;
MessageBox.Show(num.ToString());
Use string formatting with the message box:
int courseId = 0;
DialogResult result = MessageBox.Show(string.Format("Print Course No {0} ?", courseId), "Print Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
jb's answer is correct, if you need some more information MSDN has full documentation at: http://msdn.microsoft.com/en-us/library/aa984357(v=vs.71).aspx
For simple library matters, MSDN nearly always has excellent, easy to understand documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With