Valhalla Legends Forums Archive | Visual Basic Programming | VB's native Replace function

AuthorMessageTime
o.OV
@_<
Is it just me.. or is VB's Replace function really really slow..

That is.. if there is padding or it is same length strings.

[code]

Public Declare Function GetTickCount Lib "kernel32.dll" () As Long

Public Sub test3()

Dim t As Long, x As Long, test As String, faketest As String, something As Long
test = Space$(100000)
theword = "test"
replacer = "fake"
something = 1

For x = 0 To (100000 / 4) - 1
Mid$(test, (x * 4) + 1, 4) = theword
Next x

faketest = test
t = GetTickCount
Do
something = InStr(something, faketest, theword)
If something Then
Mid$(faketest, something, 4) = replacer
End If
Loop While something
MsgBox "instr: " & GetTickCount - t

faketest = test
t = GetTickCount
faketest = Replace(faketest, theword, replacer)
MsgBox "replace: " & GetTickCount - t

End Sub

[/code]
February 4, 2004, 5:25 PM
TheMinistered
So, write your own in assembly that complies to the way visual basic passes/returns data and i'll implement it into vb natively.
February 4, 2004, 6:36 PM

Search