Ok i have made a picture ;)
That will explain it a lil better.

I just need to add that certain code ***|*** to textbox2.text
but * can be 1 2 3 4 5 6 7 8 9

button2_click: if textbox1.text.contains("***|***")
then ...

Picture:
http://imageshack.us/photo/my-images/43/naamlooses.jpg/

May be you only understand what are you trying to do.

See if this helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With TextBox1
            .Text = "123|456" '// FOR TESTING.
            For Each c As Char In .Text '// loop thru all char.s.
                If Char.IsDigit(c) Then .Text = .Text.Replace(c, "*") '// .Replace char. with your char..
            Next
        End With
    End Sub

No Doesnt work :(

Works here just fine.
Try explaining the issue and not just saying sh.t don't work.

Just wondering, is it changing all #'s in the entire TextBox and you only need to change the #'s on the lines that .Contains("|")?
AndAlso, change only the first 3 #'s before the "|" and the 3 #'s after?

Hope this helps to solve your issue, although it should have been info provided by you already.

p.s. Welcome to an "IT" forum.:)

See if this helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        With TextBox1
            .Text = "123|456" '// FOR TESTING.
            For Each c As Char In .Text '// loop thru all char.s.
                If Char.IsDigit(c) Then .Text = .Text.Replace(c, "*") '// .Replace char. with your char..
            Next
        End With
    End Sub

it changes whole the code in textbox1.text to ***|***
but i need something that's finds in textbox1.text this ***|***
for example ***|*** can be
458|145
463|852
it can be anything with numbers and when it finds the values it must go in textbox2.text
now i tried to do this:

if textbox1.text.contains("145|458") then
textbox2.text = textbox1.text.replace("145|458","..."

but 145|458 is only if it is in textbox1.text but i need a random code for it cuz the ***|*** can be between 100|100 - 999|999

Found it:


Dim ary1() As String
ary1 = TextBox1.Text.Split("|")
Label1.Text = ary1(0)
Label2.Text = ary1(1)

Dim aString As String = Label1.Text
Dim bString As String = Label2.Text

aString = Strings.Right(aString, 3)
bString = Strings.Left(bString, 3)

TextBox2.Text = TextBox2.Text & aString & "|" & bString

I just finished putting this together. Hope it helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        replaceText(TextBox1)
    End Sub

    Private Sub replaceText(ByVal myCoolTextBoxToReplaceIn As TextBox)
        Dim iSi As Integer, sTemp As String
        With myCoolTextBoxToReplaceIn
            Do Until iSi >= .TextLength
                If .Text.Substring(iSi).Contains("|") Then
                    iSi = .Text.IndexOf("|", iSi)
                    sTemp = .Text.Substring(iSi - 3, 7)
                    .Text = .Text.Replace(sTemp, "***|***")
                    MsgBox(sTemp) '// get value.
                End If
                iSi += 1
            Loop
        End With
    End Sub

I just finished putting this together. Hope it helps.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        replaceText(TextBox1)
    End Sub

    Private Sub replaceText(ByVal myCoolTextBoxToReplaceIn As TextBox)
        Dim iSi As Integer, sTemp As String
        With myCoolTextBoxToReplaceIn
            Do Until iSi >= .TextLength
                If .Text.Substring(iSi).Contains("|") Then
                    iSi = .Text.IndexOf("|", iSi)
                    sTemp = .Text.Substring(iSi - 3, 7)
                    .Text = .Text.Replace(sTemp, "***|***")
                    MsgBox(sTemp) '// get value.
                End If
                iSi += 1
            Loop
        End With
    End Sub

Thank You So Much ;D
This is working 100% <3

Glad I could help. :)

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.