(ADO)Getting data from access database Memo field

M

Mike

Tax-82.54 Disc-0 Online-206.50
Instant-503.00‡CC-146‡‡Visa-139.14‡MC-‡Debit-187.26‡‡PM-3.00‡RJR-‡Lor-‡S&M-‡USST-7.00‡Other-‡Total Coupons-10.00‡Safe Fund- 300.00

I need to take the string above and break it up to look like this below
Im trying to put this into a multiline textbox. Im guessing the cross
looking things are the enterkey. Some single and some double in this example.
There could be more then that in the database.
If someone could help me i would appreciate it.

Tax-82.54 Disc-0 Online-206.50 Instant-503.00
CC-146

Visa-139.14
MC-
Debit-187.26

PM-3.00
RJR-
Lor-
S&M-
USST-7.00
Other-
Total Coupons-10.00
 
N

Nigel

One solution......

Sub FillList()
Dim sT As String, sO As String
Dim iC As Integer

sT = "Tax-82.54 Disc-0 Online-206.50
Instant-503.00‡CC-146‡‡Visa-139.14‡MC-‡Debit-187.26‡‡PM-3.00‡RJR-‡Lor-‡S&M-‡USST-7.00‡Other-‡Total
Coupons-10.00‡Safe Fund- 300.00"

With Sheets("Sheet1").ListBox1
.Clear
For iC = 1 To Len(Trim(sT))
If Asc(Mid(sT, iC, 1)) <> 135 Then
sO = sO + Mid(sT, iC, 1)
Else
.AddItem sO
sO = ""
End If
Next
End With
End Sub
 
M

Mike

Nigel
It works good except it leaves off the last part of the string
"Safe Fund- 300.00"
Any ideas
 
N

Nigel

Oops, add the line (third from bottom) to fix that.

Sub FillList
With Sheets("Sheet1").ListBox1
.Clear
For iC = 1 To Len(Trim(sT))
If Asc(Mid(sT, iC, 1)) <> 135 Then
sO = sO + Mid(sT, iC, 1)
Else
.AddItem sO
sO = ""
End If
Next
If Len(Trim(sO)) > 0 then .additem sO '< this line to fix
End With
End Sub


--

Regards,
Nigel
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

MultiSelect Textbox 11

Top