-
May 31st, 2013, 11:36 AM
#1
Thread Starter
Banned
[RESOLVED] move richtextbox1 to list1
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
-
May 31st, 2013, 12:10 PM
#2
Thread Starter
Banned
Re: move richtextbox1 to list1
Dim i As Long
Dim arrString() As String
arrString = Split(Text1.Text, ",")
For i = 0 To UBound(arrString)
List1.AddItem arrString(i)
Next
-
May 31st, 2013, 03:15 PM
#3
Re: [RESOLVED] move richtextbox1 to list1
Don't you need to split it on the new line character (vbNewLine or vbCrLf) instead of comma?
-
May 31st, 2013, 03:28 PM
#4
Thread Starter
Banned
Re: [RESOLVED] move richtextbox1 to list1
-
Jun 1st, 2013, 06:06 PM
#5
Re: [RESOLVED] move richtextbox1 to list1
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...
-
Jun 2nd, 2013, 10:54 PM
#6
Thread Starter
Banned
Re: [RESOLVED] move richtextbox1 to list1
Code:
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
sorry for the late reply was busy and out of home here it is
-
Jun 3rd, 2013, 12:05 AM
#7
Re: [RESOLVED] move richtextbox1 to list1
I agree with RB here. Why would you split on "-" instead of vbNewLine or vbCrLf ?
Split(RichTextBox1.Text, 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 example
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
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread "Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Jun 3rd, 2013, 02:56 AM
#8
Re: [RESOLVED] move richtextbox1 to list1
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:
Code:
Dim strArray As String
strArray = UBound(strRemVBCRLF) - LBound(strRemVBCRLF) 'Find Out Array Count
Well....... words fail me.
-
Jun 3rd, 2013, 10:34 AM
#9
Thread Starter
Banned
Re: [RESOLVED] move richtextbox1 to list1
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|