Reputation: 2567
I've been searching, and I found some similar questions, but none of them are solution for me, so what I need is this in Visual Basic:
I have a text (string) and I have two Arrays like this:
Dim data_array_one As String() = {"One", "Two", "Three", "Four"}
Dim data_array_two As String() = {"Five", "Six", "Seven", "Eight"}
What I need is replace every “One” in a text for “Five”, every “Two” for “Six”, and so... I've been using a simple replace function:
text1 = text1.Replace("One", "Five")
text1 = text1.Replace("Two", "Six")
...
But now array contains 24 elements, and every day it increments automatically, so I need something to do it automatically from arrays instead the actual way... Thanks in advanced.
Upvotes: 0
Views: 4011
Reputation: 748
You could try this as a simplistic fix.
dim i as single
For i = 0 to data_array_one.getlength(0)
text1 = text1.Replace(data_array_one(i), data_array_two(i))
next
However it isn't very efficient and as tcarvin said in a comment to your question, this could lead to problems with "Four" being replaced in "Fourteen".
Upvotes: 1