?
Solved

MsgBox

Posted on 2003-03-01
3
Medium Priority
?
349 Views
Last Modified: 2012-06-21
Can anyone make a suggestion on how to display a message box w/o concatenating strings of text, example:


Dim i As Integer
Dim strYachtTypes As String

    For i = 0 To frmCharters.cboYachtType.ListCount - 1
       strYachtTypes = frmCharters.cboYachtType.List(i)
       MsgBox strYachtTypes, , "Show Yacht Types"
    Next i


Say there were varying elements in the combo box,(user addition/deletion , which is apparent with cboYachtType.ListCount - 1). Obviously this code will print a msgbox the same number of times as the count of the combo box. What I want to do is display the message box 1 time with a list (will never be more than 20) of all items currently in cboYachtType.
0
Comment
Question by:McF
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 16

Expert Comment

by:twalgrave
ID: 8049860
Dim i As Integer
Dim strYachtTypes As String
dim sMsg as string

  For i = 0 To frmCharters.cboYachtType.ListCount - 1
      strYachtTypes = strYachtTypes & vbcrlf & frmCharters.cboYachtType.List(i)
   Next i
'Now remove the leading VBCRLF from the beginning of the string
     strYachtTypes =mid$(strYachtTypes,3)
      MsgBox strYachtTypes, , "Show Yacht Types"
0
 

Accepted Solution

by:
applayer earned 200 total points
ID: 8049869
The code below may help you out...

------------------------------------
Dim i As Integer ' used for looping
Dim strMessage As String ' used to hold the message
 
' this loop fills the combo box with all of the types  For i = 1 To 20
  Combo1.AddItem "Yacht Type " & i
Next i
 
' builds the string which can display the types  
For i = 1 To 20
  strMessage = strMessage & Combo1.List(i - 1) & vbNewLine
Next i
 
MsgBox strMessage ' show the yacht types
0
 

Author Comment

by:McF
ID: 8050206
Thanks, that cured my problem. Looking at about 16 forms, I simply was blind to the solution, however, I have the people that answered my question to thank for it.  
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question