By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,045 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,045 IT Pros & Developers. It's quick & easy.

Reorganising the contents of a list box

P: n/a
I have a list box that has a list of ID numbers for people. The box
actually shows their names though. I want to take this list and
programmatically put it into a text box on the same form in the format,
'Name1, Name2, Name3, Name4, etc.'.

How do I take the contents of the list box and programmatically add it into
the text box in that format?

dixie
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

How 'bout this:

==== begin code ====
dim lst as listbox
dim str as string
dim i as integer

set lst = Me!ListBox_Name
for i = 0 to lst.listcount
str = str & lst.column(1,i) & ","
next i
' get rid of the trailing comma
str = left$(str,len(str)-1)

Me!TextBox_name = str
===== end code ====

Syntax of .Column(): .Column(index, row)

Therefore, .Column(1,i) means pull the value of the 2 column (the index
is a zero-based index) on the row indicated by i.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQRwG+oechKqOuFEgEQLQnwCg/AJ2MOdJYARYPtyLxSL0yiq/dOMAoN4+
OJweR9TpXM9OTIswC0IEuoLA
=lEVD
-----END PGP SIGNATURE-----
dixie wrote:
I have a list box that has a list of ID numbers for people. The box
actually shows their names though. I want to take this list and
programmatically put it into a text box on the same form in the format,
'Name1, Name2, Name3, Name4, etc.'.

How do I take the contents of the list box and programmatically add it into
the text box in that format?


Nov 13 '05 #2

P: n/a
Thanks for that MG. It worked straight away with very little fiddling.

dixie

"MGFoster" <me@privacy.com> wrote in message
news:5G*******************@newsread1.news.pas.eart hlink.net...
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

How 'bout this:

==== begin code ====
dim lst as listbox
dim str as string
dim i as integer

set lst = Me!ListBox_Name
for i = 0 to lst.listcount
str = str & lst.column(1,i) & ","
next i
' get rid of the trailing comma
str = left$(str,len(str)-1)

Me!TextBox_name = str
===== end code ====

Syntax of .Column(): .Column(index, row)

Therefore, .Column(1,i) means pull the value of the 2 column (the index
is a zero-based index) on the row indicated by i.

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQRwG+oechKqOuFEgEQLQnwCg/AJ2MOdJYARYPtyLxSL0yiq/dOMAoN4+
OJweR9TpXM9OTIswC0IEuoLA
=lEVD
-----END PGP SIGNATURE-----
dixie wrote:
I have a list box that has a list of ID numbers for people. The box
actually shows their names though. I want to take this list and
programmatically put it into a text box on the same form in the format,
'Name1, Name2, Name3, Name4, etc.'.

How do I take the contents of the list box and programmatically add it into the text box in that format?

Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.