?
Solved

How do you call in a variable in a MsgBox?

Posted on 2003-03-27
5
Medium Priority
?
131 Views
Last Modified: 2010-04-07
I know this isn't a hard question but I'm a new at VB. This is my code:

Private Sub Command1_Click()
Dim answer As Integer
Dim milesover As Integer
Dim basefine As Integer
Dim mphfine As Integer

Text1.Text = milesover
basefine = 125
mphfine = 8
answer = basefine + (milesover * mphfine)

MsgBox "The violator owes: answer", vbCritical + vbOKOnly + vbInformation, "Promp"
End Sub

I'm trying to call in 'answer' so it says the violator owes: (X amount of money). I've tryed moving the quotation marks to before it but that didn't seem to work. I'm a newb at VB but I know some stuff about c++. Thanks for any help.
0
Comment
Question by:CxD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 39

Expert Comment

by:appari
ID: 8221940
chang
MsgBox "The violator owes:" &  answer & ", vbCritical + vbOKOnly + vbInformation, "Promp"
to

MsgBox "The violator owes: answer", vbCritical + vbOKOnly + vbInformation, "Promp"
0
 
LVL 39

Accepted Solution

by:
appari earned 300 total points
ID: 8221946
sorry its reversed:)

change
MsgBox "The violator owes: answer", vbCritical + vbOKOnly + vbInformation, "Promp"

to

MsgBox "The violator owes:" &  answer & ", vbCritical + vbOKOnly + vbInformation, "Promp"

0
 
LVL 2

Expert Comment

by:SylvainPouliot
ID: 8221949
You were on the right track... but I suppose you had an error with Datatype Conversion...
Try


MsgBox "The violator owes: " + str(answer), vbCritical + vbOKOnly + vbInformation, "Promp"
0
 

Author Comment

by:CxD
ID: 8221960
Thanks for the help and fast responce! I know it was a easy question but I'm new at this :)
0
 
LVL 39

Expert Comment

by:appari
ID: 8221966
one extra double quote in my previous post
change to

MsgBox "The violator owes:" &  answer , vbCritical + vbOKOnly + vbInformation, "Promp"

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month12 days, 17 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question