richtextbox1 has
116.228.55.184:80
116.236.216.116:8080
112.231.65.71:80
113.108.92.104:80
110.159.78.113:8118
111.255.136.231:8888
119.167.231.73:8080
117.211.123.60:3128
117.211.123.60:80
how do i move all of it to list1 , the list is larger
Printable View
richtextbox1 has
116.228.55.184:80
116.236.216.116:8080
112.231.65.71:80
113.108.92.104:80
110.159.78.113:8118
111.255.136.231:8888
119.167.231.73:8080
117.211.123.60:3128
117.211.123.60:80
how do i move all of it to list1 , the list is larger
Dim i As Long
Dim arrString() As String
arrString = Split(Text1.Text, ",")
For i = 0 To UBound(arrString)
List1.AddItem arrString(i)
Next
Don't you need to split it on the new line character (vbNewLine or vbCrLf) instead of comma?
no bro thats ok now
First: I am not "bro"...
And second: I am still curious how you actually resolved it.. Sample text you posted is multiline so how in the world is it going to be splited on comma and not on the new line character?
Remember that there are lots of people browsing this forum for samples and answers...
sorry for the late reply was busy and out of home here it isCode:Private Sub Command4_Click()
Dim strRemVBCRLF() As String
Dim strArray As String
RichTextBox1.Text = Replace(RichTextBox1.Text, vbLf, vbCrLf) 'Remove bad chars
RichTextBox1.Text = Replace(RichTextBox1.Text, vbCr, vbCrLf) ' ""
strRemVBCRLF() = Split(RichTextBox1.Text, vbCrLf & "-") 'Split each line
strArray = UBound(strRemVBCRLF) - LBound(strRemVBCRLF) 'Find Out Array Count
For x = 0 To strArray
List1.AddItem strRemVBCRLF(x) 'Add each line
Next
End Sub
I agree with RB here. Why would you split on "-" instead of vbNewLine or vbCrLf ?
I also don't understand your code in the previous post. Where is "-" coming from? Your code in Post2 is correct. All you need to do is replace "-" by vbnewline or vbcrlf, See this exampleQuote:
Split(RichTextBox1.Text, vbCrLf & "-")
Code:Dim i As Long
Dim arrString() As String
arrString = Split(Text1.Text, vbNewLine)
'arrString = Split(Text1.Text, vbCrLf)
For i = 0 To UBound(arrString)
List1.AddItem arrString(i)
Next
Looking at the code in Post #6, with respect to the RichTextBox contents (and ignoring the appearance, late in the day, of the mysterious "-"):
If each line terminates with vbCr then there's going to be an extra 'null' item added to the ListBox
If each line terminates with vbLf then the second and subsequent items will be prefixed by a vbCr
If each line terminates with vbCrLf then each item in the ListBox is going to be followed by a 'null' item and the second and subsequent items will be prefixed by a vbLf
In the 2nd and 3rd cases, this is going to make for some interesting 'issues' when OP decides to extract an Item and then compare it to something, or heaven forbid, attempts to use it as an IP Address.
and as for:
Well....... words fail me.Code:Dim strArray As String
strArray = UBound(strRemVBCRLF) - LBound(strRemVBCRLF) 'Find Out Array Count
Yeh thanks guys , em like u said doogle null gets added but i wipe out all extra space's and unwante chars then move them all ill try urs and other code again thanks guys