[RESOLVED] move richtextbox1 to list1-VBForums
Results 1 to 9 of 9

Thread: [RESOLVED] move richtextbox1 to list1

  1. #1

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Resolved [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

  2. #2

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    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

  3. #3

  4. #4

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    Re: [RESOLVED] move richtextbox1 to list1

    no bro thats ok now

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,135

    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...

  6. #6

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    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

  7. #7
    Super Moderator Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    11,928

    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
    The poster formerly known as koolsid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved

    Microsoft MVP: 2011 - Till Date IMP Links : Acceptable Use Policy, FAQ

    MyGear:
    Sony VGN-FZ27G with a triple boot between (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008) and (Win7+Office 2010+VS2010) || Sony VPCCB-45FN with a Win7+Office 2010+VS2010. VM: (XP+Office 2003+VB6), (VISTA+Office 2007+VS2008), (Win8+Office 2010+VS2012) || Mac Book Pro (10.6.8) with Office 2011

  8. #8
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    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.

  9. #9

    Thread Starter
    Banned
    Join Date
    Nov 2012
    Posts
    1,171

    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
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.