I reread your question and I think this is what you asked for
setup : a window , an editfield and a button
Defined this method for the window
Protected Function Rephrase(theString As String, Delimiter As String,
newDelimiter As String,AtPosition As Integer) As String
Dim anArray() As String
Dim i As Integer
Dim newString As String
anArray = split(theString,Delimiter)
newString = ""
for i = 0 to UBound(anArray)
if i = AtPosition then
newString = newString +anArray(i) + newDelimiter
Else
newString = newString +anArray(i) + Delimiter
end if
next
Return newString
End Function
action code on the button:
Sub Action()
editfield1.Text = Rephrase(editField1.Text,"111111","222222",2)
End Sub
in the editfield1 you can insert your teststring and then click the
button
Of course multiple enhancements can be put on the code so the
parameters passed to the function are easier to modify, but I hope
you get the idea
hth
Bart (going to bed now)
On 4-sep-06, at 23:20, RBNUBE wrote:
I had thought about using an array and then splitting it, but it
shreds the
string into pieces and removes the delimiter which then has to be
added back
to the string in the correct places and replaced at the correct
location.
I am able to use this by extending your code as below, but I was
hoping
there would be something simpler and possibly more efficient.
Thanks for the example! Is there any way to improve it or the
extended
version below?
I took your example and extended it to this:
Dim aString As String
Dim arString() As String
Dim theFinalString as String
Dim i as Integer
aString =
"AAAAAAAAAAAAAAAAAAAA111111BBBBBBBBBBBBBBBBB111111CCCCCCCCCCCCCCCCCCC1
11111D
DDDDDDDDDDDDDDDDD"
arString = Split(aString,"111111")
For i = 0 to UBound(arString)
If i = 1 then
theFinalString = theFinalString + arString(i) + "222222"
ElseIf i > 1 and i <> UBound(arString) then
theFinalString = theFinalString + arString(i) + "111111"
Else
theFinalString = theFinalString + arString(i)
End If
Next
MsgBox theFinalString
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>