Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2005
    Posts
    144

    Unanswered: Proper Syntax for Message Box

    I want to include a variable in a text string in my message box, but I'm not quite sure as to what the correct syntax is.

    Code:
    MsgBox(strMsg, vbQuestion, "There are currently '&myDocCount&' documents open." = vbOK
    I need something similar to this code, whereas 'myDocCount' would be calculated prior to the code being executed. The resulting message box string might look something like this:

    There are currently 5 documents open.

    I know I'm missing something small here, so can anyone lend a hand?

  2. #2
    Join Date
    Feb 2004
    Location
    Canada
    Posts
    133
    Create strMsg first:

    strMsg = "There are currently " & myDocCount & " documents open."

    MsgBox(strMsg)
    Last edited by bmacr; 03-08-05 at 22:05.

  3. #3
    Join Date
    Nov 2003
    Posts
    1,487
    Code:
    strMsg = "Blah...Blah...Blah."
    
    If MsgBox(strMsg, vbQuestion, "My Mseesage Box Title:" & myDocCount & " documents open.") = vbOK Then 'redundant
    ' whatever code...
    End If
    OR
    Code:
    strMsg = "Blah...Blah...Blah."
    
    MsgBox strMsg, vbQuestion, "My Mseesage Box Title:" & myDocCount & " documents open."
    OR
    Code:
    strMsg = "Blah...Blah...Blah."
    MsgBox strMsg, vbQuestion + vbOkCancel, "My Mseesage Box Title:" & myDocCount & " documents open."

    and on....and on....and on....

    Last edited by CyberLynx; 03-09-05 at 01:04.

  4. #4
    Join Date
    Jul 2004
    Location
    Inverurie
    Posts
    628
    Check this for additional information on it:
    (I didn't write it)
    Attached Files Attached Files

Posting Permissions

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