2
Reply

Perform remove on multi-line textbox

Scott

Scott

May 14 2010 5:30 PM
5.2k
Hi,

Aim:
Read the text from a multi-line textbox line by line to remove all but an 8 character ID.

For example:
"        Test ID: 12345678"
"        Test ID: 12345678"

I wish to retrieve the ID's only and show on 1 line with a delimiter,

For example:
"12345678, 12345678"

I can do this on a single line using the following:

     Private Sub btnTrim_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTrim.Click

        Dim sTemp As String
        Dim sCount As Integer

        sTemp = ""

        'loads a text file into the sTemp string
        sTemp = GetFileContents(txtPath.Text)

        'remove text from begining of the string
        sTemp = sTemp.Remove("0", "10")

        'check how long the sTemp string is now
        sCount = sTemp - txtLength.Text
        'remove all text after the txtLength number
        sTemp = sTemp.Remove(txtLength.Text, sCount)

        txtData.Text = sTemp

    End Sub

I've tried to replicate this on a multi-line using Splits, Substrings and a For...Each loop - but have just ended up with a headache..

Any help would be greatly appreciated!


Answers (2)