[Webinar] Streamline your web hosting managementRegister Today

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

MsgBox

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
McF
Asked:
McF
1 Solution
 
twalgraveCommented:
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
 
applayerCommented:
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
 
McFAuthor Commented:
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

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

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