CxD
asked on
How do you call in a variable in a MsgBox?
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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"
Try
MsgBox "The violator owes: " + str(answer), vbCritical + vbOKOnly + vbInformation, "Promp"
ASKER
Thanks for the help and fast responce! I know it was a easy question but I'm new at this :)
one extra double quote in my previous post
change to
MsgBox "The violator owes:" & answer , vbCritical + vbOKOnly + vbInformation, "Promp"
change to
MsgBox "The violator owes:" & answer , vbCritical + vbOKOnly + vbInformation, "Promp"
MsgBox "The violator owes:" & answer & ", vbCritical + vbOKOnly + vbInformation, "Promp"
to
MsgBox "The violator owes: answer", vbCritical + vbOKOnly + vbInformation, "Promp"