Results 1 to 2 of 2

Thread: One more question - about msgbox..

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Apr 2002
    Posts
    27

    One more question - about msgbox..

    OK, got my code from my previous post working, here it is:
    VB Code:
    1. Private Sub CmdSum_Click()
    2. Set Comm = Worksheets(2).Range("J12:J50")
    3. showComm = Application.WorksheetFunction.Sum(Comm)
    4.  
    5. Set Mort = Worksheets(2).Range("L12:L50")
    6. showMort = Application.WorksheetFunction.Sum(Mort)
    7.  
    8. Set Life = Worksheets(2).Range("M12:M50")
    9. showLife = Application.WorksheetFunction.Sum(Life)
    10.  
    11. Set Home = Worksheets(2).Range("N12:N50")
    12. showHome = Application.WorksheetFunction.Sum(Home)
    13.  
    14. Set Profit = Worksheets(2).Range("J12:N50")
    15. showProfit = Application.WorksheetFunction.Sum(Profit)
    16.  
    17. End Sub

    I now want to use a Msgbox to make it look like this:

    "Total Commission = (Comm)
    Total Mortgage Fee = (Mort)
    Total Life Fee = (Life)
    Total Home Insurance = (Home)
    Total Profit for the company = (Profit)"

    Where the words in brackets are the variables from the above code, and formatted like above (a new line for each piece of info). Not done a lot with Msgboxes, so can anyone help?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: One more question - about msgbox..

    This isn't complete, but it will give you the idea.
    MsgBox "Total Commission = " & showComm & vbcrlf & _
    "Total Mortgage Fee = " & showMort & vbcrlf & _
    "Total Life Fee = " & showLife

    the key is the vbCrLf which will put a new line in the msgbox.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

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



Click Here to Expand Forum to Full Width