Converting a list into a string format

Hi
  I'm developing part of an application where there are 2 list boxes. In one of the list boxes there is a list of choices that the user can choose. Once the user has picked something from the list it goes into the second list box. The problem is that when the information is sent to the database, the database can't read it because it reads it in a string format. Meaning that if the items in the list are 1,2,3,4.. the database can only read it as 1,2,3,4..not                               1
                                           2
                                           3
                                           4.

How do i convert the list format above into a string with commas in between all the choices?  

Thanks in advance
nebula786Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

nebula786Author Commented:
Edited text of question.
0
TimCotteeHead of Software ServicesCommented:
IF I understand correctly then this should do the trick,

strList = ""
For intCount = 0 to List2.ListCount - 1
  List2.ListIndex = intCount
  strList = strList & List2.Text & iif(intCount = List2.ListCount - 1,"",",")
Next

Though I can never remember whether listindex is 0 based or 1 based so you may need to change it to 1 to list2.listcount instead etc.
0
vbWayneCommented:
What exactly do you mean?
1,2,3,4 are the values or the list index
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

nebula786Author Commented:
What do you mean you might have to change it to 1 to list2.listindex?
0
vbWayneCommented:


'run it and see if it's what you want
'Tim has given you 1,2,3,4

strList = ""
For intcount = 0 To List1.ListCount - 1
  List1.ListIndex = intcount
  strList = strList & List1.Text & IIf(intcount = List1.ListCount - 1, "", ",")
  iarray(intcount) = strList
Next


MsgBox strList
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
matrix717Commented:
If I I understood is right, you want to record in the database what the user choose from the listbox, so if this is the case this should works:

Dim base1 as database
dim record1 as recordset

set base1=opendatabase("Whatever\yourdatabase.mdb")

set record1=base1.openrecordset("yourrecordset",2)

with record1

..addnew
!fieldname = list1
..update

end with


This will save what the user selected from the listbox

0
TimCotteeHead of Software ServicesCommented:
Seems like the accepted answer is just a variation on my original!
0
vbWayneCommented:
I agree...
it wasn't meant to be the answer it was a statement in reference to...
From: nebula786
 Date: Friday, January 14 2000 - 08:00AM PST  ....
I worded it as this....
look at what Tim has sent you and see if it's what you need...

Wayne

ps..Sorry about the misunderstanding Tim, I wasn't after your points I was advising nebula786 to check out your answer because it was what he/she needed and

0
TimCotteeHead of Software ServicesCommented:
Didn't mean to have a go at you Wayne, but well these things happen, I guess if nebula786 felt so inclined he/she could contact customer service and sort it out but it don't matter that much to me as long as the problem is sorted.
0
nebula786Author Commented:
I apologize Tim. This was my first time asking a question, and accepting an answer. I thought I could accept both answers. Sorry for the misunderstanding.  
0
nebula786Author Commented:
I've contacted customer service. Hopefully this problem will be taken care of. Once again, I apologize.
0
darinwCommented:
I apologize for the very long delay in answering your post in the Customer Service area nebula786.

I will post a question for Tim in this section for the appropriate points.

darinw
Customer Service
0
vbWayneCommented:
Coool...:}
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.