How to Split MultiLine TextBox into a ListBox

eDIN

New member
Local time
Today, 13:49
Joined
Nov 21, 2011
Messages
7
In My Table there is a Memo Field.
It's representing (on Form) by a MultuLine textBox
I want get the lines of that TextBox into a ListBox (on the same Form).

Like in Excel:
Dim v As Variant
v = Split(Range("A1").Value, vbLf)
ListBox1.List = v

What is the Way?
Thanks in Advance.
 
I was trying several times, but nothing happend.
Here is one of my try:

Dim i As Long
Dim a() As String
a = Split(txNm.Text, vbCrLf)
For i = LBound(a) To UBound(a)
LbNm.AddItem a(i)
Next

What's happend - ListBox received focus - and that's All.

Could You write the code, please.
thanks.
 
Just remember to make sure the following properties are set as follows:

RowSource Type = Value List
Column Count = 1
Column Width = x
Bound Column = 1

where x is whatever you want it to be, in most cases the same as the Width of the listbox.
 
EveryThing Checked but - No Result.
Any More Idea, Please.
Thanks for Your Effort.
 
And if you use vba.split() you can also use vba.join()
Code:
Dim var
var = [COLOR="DarkRed"]Split[/COLOR](Me.Textbox1, vbCrLf)
Me.MyList.RowSource = [COLOR="DarkRed"]Join[/COLOR](var, ";")
 
LagBolt,
You are a Realy Maestro - It Works.
I will visit Your Site.
Thanks !

PS
Could You meaby explain - why did my previously attemptings not working. Where is Mistake. It's a Clear Code - isn't it ?

AnyWay - AnyCase - ThanksAgain.
 
eDin,

Code:
Dim i As Long
Dim a as variant
a = Split(txNm.Text, vbCrLf)
For i = LBound(a) To UBound(a)
LbNm.AddItem a(i)
Next i

I think it may have worked if you had defined 'a' as a variant rather than trying to define it as an array.

Just out of interest I set the Row Source Type to Value List, tried it and found this to work.

Code:
Dim i As Long
Dim a As Variant
Me.txNm.SetFocus
a = Split(txNm.Text, vbCrLf)
LbNm.RowSource = ""
For i = LBound(a) To UBound(a)
    LbNm.AddItem a(i)
Next i

I see Listbox.clear seems to have been done away with. No wonder I couldn't find it. :rolleyes:
 
Last edited:
NansCombe,
Thanks, but... - it doesn't work (on myComp).
I'm eager to know - Why? :confused:
 
Yes, of course.
I'll do it tomorrowEvening.
Actually, I'm on a shorTrip.
Best Regards.
 
Hello vbaInet
Here is a VeryVery stripped version of myDB
Thank's for You Efforts.
eDIN
 

Attachments

Right, I don't have Access 2010 installed on my machine. SAVE AS an older version and re-upload.
 

Users who are viewing this thread

Back
Top Bottom