Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 132
  • Last Modified:

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.
0
CxD
Asked:
CxD
  • 3
1 Solution
 
appariCommented:
chang
MsgBox "The violator owes:" &  answer & ", vbCritical + vbOKOnly + vbInformation, "Promp"
to

MsgBox "The violator owes: answer", vbCritical + vbOKOnly + vbInformation, "Promp"
0
 
appariCommented:
sorry its reversed:)

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

to

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

0
 
SylvainPouliotCommented:
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
 
CxDAuthor Commented:
Thanks for the help and fast responce! I know it was a easy question but I'm new at this :)
0
 
appariCommented:
one extra double quote in my previous post
change to

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

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now