Results 1 to 5 of 5

Thread: MsgBox? (A97)

  1. #1
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    MsgBox? (A97)

    Good Morning,

    strInput=a number
    strHW= a number

    In the end of my code I would like to put a msgbox that takes strInput and strHW and puts something like this: "For strInput your ENP will be strHW". Currently this is what I have and it returns exactly what I have...it should return: For 35 your ENP is 387......what am I missing?

    MsgBox = ("For strInput & " " your ENP is & " " strHW ")

    Thanks for your help.

    <img src=/S/crossfingers.gif border=0 alt=crossfingers width=17 height=16>
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: MsgBox? (A97)

    Try

    <font face="Georgia">MsgBox "For " & strInput & ", your ENP is " & strHW</font face=georgia>

    Explanation: put the literal texts that don't change in quotes. In this case, these are <font face="Georgia">"For "</font face=georgia> and <font face="Georgia">", your ENP is "</font face=georgia>.

    Don't put quotes around the variables <font face="Georgia">strInput</font face=georgia>and <font face="Georgia">strHW</font face=georgia>.

    Concatenate the parts by placing ampersands & between them (outside the quotes). In this case, the structure is

    <font face="Georgia">"literal" & variable & "literal" & variable</font face=georgia>

  3. #3
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox? (A97)

    Hans,

    Thanks for the quick reply.....I've tried your suggestion prior to my original post and got an unusual message...when I tried your suggestion again...I got the same error message...perhaps you have a suggestion for the error....

    Compile Error: Function call on left-hand side of assignment must return Variant or Object.

    Thanks again.
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: MsgBox? (A97)

    In your original post, you had <font face="Georgia">MsgBox =</font face=georgia>. You can't do that - you can't assign a value to the built-in function MsgBox.

    If you just want to display a message, call MsgBox as a procedure:

    MsgBox "This is a warning"

    Note that there is no = after MsgBox. This way, the message box will display the text and one button - the default OK button.

    If you want to display a text and two or three buttons, for instance OK and Cancel, or Yes, No and Cancel, you want to know which button is clicked by the user. In that case, you call MsgBox as a function:

    If MsgBox("Do you want to continue?", vbYesNo Or vbQuestion) = vbYes Then
    ' do something
    Else
    ' do something else
    End If

    In this case, the = doesn't assign a value, but compares the return value of the MsgBox function to vbYes.

  5. #5
    5 Star Lounger
    Join Date
    Feb 2001
    Location
    Louisville, Kentucky, USA
    Posts
    605
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: MsgBox? (A97)

    Thanks Hans....that's the peice I was missing....I appreciate it!
    Roberta Price <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •