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!

Simple List Box

Status
Not open for further replies.

mans

Programmer
Mar 18, 2000
136
AU
Hello,<br><br>I have a list box (VB6) which displays two fields from Table1, Surname and FirstName.&nbsp;&nbsp;The List box has these two fields delimited by a comma (and space) as per the code below.&nbsp;&nbsp;I would like to know what code I can use to then save these two fields separately from the List box into Table2 under the Surname and FirstName fields.&nbsp;&nbsp;The second set of code below shows the code I use to save both fields in List1 into a single field into Table2 (the full name).&nbsp;&nbsp;As I said, I would appreciate it if somebody could let me know what code I can use to save the Surname and FirstName separately from List1.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Do While Not rww.EOF<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List1.AddItem rww!surname & &quot;, &quot; & rww!FirstName <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rww.MoveNext<br>&nbsp;&nbsp;&nbsp;&nbsp;Loop<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For I = 0 To List1.ListCount - 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List1.Selected(I) = True<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next<br><br><br>For I = 0 To List1.ListCount - 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List1.ListIndex = I <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs!Name = List1.Text<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.Update<br>Next<br><br>Thank You<br>
 
Maybe something like this<br><br>For I = 0 To List1.ListCount - 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List1.ListIndex = I <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs!Name = left( List1.text , instr( List1.Text, &quot;,&quot; )-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs!surname = right( list1.text, len(list1.text) - instr( List1.text,&quot;,&quot;))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.Update<br>Next<br><br> <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk drive?
 
Thank you for your response.&nbsp;&nbsp;How about if I have three field instead of two ???<br><br>Thanks
 
dim col1 as long<br>dim col2 as long<br><br>For I = 0 To List1.ListCount - 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.AddNew<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;List1.ListIndex = I <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;col1 = instr( List1.Text, &quot;'&quot;)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;col2 - instr( col1, List1.Text, &quot;,&quot; )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs!Name = left( List1.text , col1-1)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs!middle = mid( List1.textm col1, col1-col2 )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs!surname = right( list1.text, len(list1.text) - col2)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rs.Update<br>Next<br><br> <p>Clayton T. Paige<br><a href=mailto:cpaige@home.com>cpaige@home.com</a><br><a href= Snail</a><br>Clayton T. Paige<br>
Programmer Extraordinaire <br>
========================================================<br>
"Who General Failure? and Why is he reading my disk drive?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top