Hi Coders,

I have a minor problem that I would like to try and resolve. I am pasting data from an Excel spreadsheet and and adding a 0 to the start of each 9 digit string it's it's missing (thanks to the help of Rev Jim. This works great if I'm pasting from notepad but from excel I see from this line of code

RTBUserID.Text = RTBUserID.Text.Substring(1, RTBUserID.TextLength - 1)

that there seems to be a carrage return (denoted by a square)

System.Windows.Forms.RichTextBox, Text: 62818972 " & vbLf & "62819154 " & vbLf & "62999101 " & vbLf & "62985054 " & vbLf & "...}

Question is, how to I remove it.

I have tried the following code but to no avail..

For x As Integer = 0 To RTBUserID.Text.Length - 1
            RTBUserID.SelectionStart = x
            RTBUserID.SelectionLength = 1
            If RTBUserID.SelectedText = vbTab OrElse RTBUserID.SelectedText = vbCr OrElse RTBUserID.SelectedText = " " Then
                RTBUserID.Text = RTBUserID.Text.Replace(vbCr, "")
                RTBUserID.Text = RTBUserID.Text.Replace(vbTab, "")
                RTBUserID.Text = RTBUserID.Text.Replace(" ", "")
            End If
        Next

Thnaks in advance.

Sorted with the following:

For x As Integer = 0 To RTBUserID.Text.Length - 1
            RTBUserID.SelectionStart = x
            RTBUserID.SelectionLength = 1
            RTBUserID.Text = RTBUserID.Text.Replace(vbTab, "")
        Next
commented: :) for IT +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.