Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Items listed in a combo box sequentially

Status
Not open for further replies.

RSH

Technical User
Jun 15, 2000
55
US
I have a combo box with about 15 items listed. I can print these fine at the form level but must scroll the list and select an item then hit a command button for each item.&nbsp;&nbsp;I would like to be able to hit a command button and sequence down through the list, printing each one as it comes aboard,<br>until all were printed. I could do this in basic with a loop but VB is not basic and is always complaining about going to, or going sub.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73&nbsp;&nbsp;&nbsp;RSH
 
I I would say that in c/c++ what you want to do I think should be done with a stack.<br><br>There is some info on stacks in the msdn library. <br><br>ex:<br>Stacking Property<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br><br>Sets a value that determines whether all the series in the chart are stacked.<br><br>Syntax<br><br>object.Stacking [ = boolean]<br><br>The Stacking property syntax has these parts:<br><br>Part Description <br>object Anobject expression that evaluates to an object in the Applies To list. <br>boolean ABoolean expression that controls whether all chart series are stacked, as described in Settings. <br><br><br>Settings<br><br>The settings for boolean are:<br><br>Setting Description <br>True All chart series are stacked. <br>False (Default) Chart series are not stacked. <br><br>
 
You can move to a list item in a combo box by using the command<br><br><b><br>combo1.listindex = 0<br></b><br><br>The list in a combo box is zero based.&nbsp;&nbsp;The listcount property contains the number of items in the list.&nbsp;&nbsp;Therefore, to loop and select each item, the code looks like:<br><br><b><br>dim i as integer<br><br>for i = 0 to combo1.listcount - 1<br>&nbsp;&nbsp;&nbsp;&nbsp;combo1.listindex = i<br>next i<br></b><br><br>You can also execute a command button in code by setting the command button equal to true.<br><br>To put the concepts together, open a new project and add a combo box and two command buttons to the form.<br><br>Then paste the following code into the form:<br><br><b><br>Option Explicit<br><br>Private Sub Command1_Click()<br><br>&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Item to print is &quot; & Combo1.Text<br><br>End Sub<br><br><br>Private Sub Command2_Click()<br><br>&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;For i = 0 To Combo1.ListCount - 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combo1.ListIndex = i<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Command1 = True<br>&nbsp;&nbsp;&nbsp;&nbsp;Next i<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Sub<br><br>Private Sub Form_Load()<br>&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Integer<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;For i = 0 To 14<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Combo1.AddItem &quot;Item &quot; & i<br>&nbsp;&nbsp;&nbsp;&nbsp;Next<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>End Sub<br></b><br><br>This should give you an idea of how to make this work in your situation.&nbsp;&nbsp;Obviously the code in Command1_Click would be the code to print the item.<br><br>Hope this helps.<br>Steve<br><br><br>
 
Edward Tisdale/SteveBlum<br>Thanks for the data. Will print it out and look at it in the am.&nbsp;&nbsp;Since asking the question I poked around and came up with a sort of solution.&nbsp;&nbsp;All my items are listed as public subs which I can go down the list with calls and also<br>call the subs from the combo list.&nbsp;&nbsp;Hey it works.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;73&nbsp;&nbsp;RSH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top