Multiline textbox & listbox, I forgot how! - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Multiline textbox & listbox, I forgot how!

phph Posts: 393Member
[b][red]This message was edited by pht at 2004-9-9 20:55:43[/red][/b][hr]
I have a text box with a list of items in it, each line has one item.
what I'd like to do is add each line of text to the list box.
kinda like:
[code]
list1.additem text1.line1
list1.additem text1.line2
etc
[/code]
I know that syntax is invalid, but it gets my idea across.

here is what I have so far:
[code]
Dim ItemNumber As Long
If Text1.Text = "" Then
Timer2.Enabled = False
Exit Sub
Else
ItemNumber = 0
List1.AddItem Text1.Text, ItemNumber
ItemNumber = ItemNumber + 1
End If
[/code]
Currently my code is in a timer, and this syntax simply adds the whole textbox to the listbox as one item, which I figured it would do... but was hoping it wouldnt ;)

So basically what i need is something that either:
A: adds the first line to the listbox then deletes the first line from the textbox.
or
B: adds each line to the textbox using my makeshift array "ItemNumber" to specify which line to extract and add to the listbox.

Any ideas?

p.s. - Hi guys!

**EDIT**
also, do any of you know how I can extract a list of hyperlink adresses to a text file? like have the webbrowser control go to a page, then upon documentcomplete, have the a textbox list all of the hyperlink urls on that page?
[red]ph[/red][blue][/blue][red]t[/red]
[red]http://jmcivor.com[/red]
[red][email protected][/red]


Comments

  • tlcbctlcbc Posts: 2Member
    Assign the text to a string first and then pull that string apart to add each line. The following should do it:

    dim strTemp as string
    dim intPos as integer

    strTemp = text1.text
    intPos = instr(strTemp,vbNewline)
    do until intPos=0
    List1.AddItem left(strTemp,intPos-1)
    strTemp = mid(strTemp(intPos+2))
    intPos=instr(strTemp,vbNewLine)
    loop

    List1.AddItem strTemp


    NOTE: This assumes each line in the textbox has a value on it - if not you will have to check for blank lines as well.

    Regards,
    Terry
    : [b][red]This message was edited by pht at 2004-9-9 20:55:43[/red][/b][hr]
    : I have a text box with a list of items in it, each line has one item.
    : what I'd like to do is add each line of text to the list box.
    : kinda like:
    : [code]
    : list1.additem text1.line1
    : list1.additem text1.line2
    : etc
    : [/code]
    : I know that syntax is invalid, but it gets my idea across.
    :
    : here is what I have so far:
    : [code]
    : Dim ItemNumber As Long
    : If Text1.Text = "" Then
    : Timer2.Enabled = False
    : Exit Sub
    : Else
    : ItemNumber = 0
    : List1.AddItem Text1.Text, ItemNumber
    : ItemNumber = ItemNumber + 1
    : End If
    : [/code]
    : Currently my code is in a timer, and this syntax simply adds the whole textbox to the listbox as one item, which I figured it would do... but was hoping it wouldnt ;)
    :
    : So basically what i need is something that either:
    : A: adds the first line to the listbox then deletes the first line from the textbox.
    : or
    : B: adds each line to the textbox using my makeshift array "ItemNumber" to specify which line to extract and add to the listbox.
    :
    : Any ideas?
    :
    : p.s. - Hi guys!
    :
    : **EDIT**
    : also, do any of you know how I can extract a list of hyperlink adresses to a text file? like have the webbrowser control go to a page, then upon documentcomplete, have the a textbox list all of the hyperlink urls on that page?
    : [red]ph[/red][blue][/blue][red]t[/red]
    : [red]http://jmcivor.com[/red]
    : [red][email protected][/red]
    :
    :
    :

Sign In or Register to comment.