Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27355

replace with arrays

$
0
0
Code:

Dim newstr() As String = {"1", "2", "3", "4", "5", "6"}
    Dim oldstr() As String = {"a", "b", "c", "d", "e", "f"}
    Dim notreplaced As String
    Dim x As Integer = Nothing
    Dim i As Integer = 0

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        notreplaced = TextBox1.Text
        For num As Integer = 0 To oldstr.Length - 1

            text = notreplaced.Replace(oldstr(num), newstr(num))

        Next
        SendKeys.Send(text)
        SendKeys.Send("{enter}")
    End Sub

Why does it only replace the last string from the array...

I write into textbox -> a b c d e f and it sends a b c d e 6

What did I wrong, why is it replacing only the 6th element and how to make it send 123456 replacing oldstr(0) with newstr(0), oldstr(1) with newstr(1) and so on...

thx

Viewing all articles
Browse latest Browse all 27355


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>