by Der Shorty (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 4.0 (32-bit)
Difficulty: Unknown Difficulty
Originally Published: Tue 21st May 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Ever tried Copy memory ?
API Declarations
Private Declare Function GetTickCount Lib "kernel32" () As Long
Dim sSave As String, Cnt As Long, T As Long, Pos As Long, Length As Long
Const mStr = "Hello "
Length = Len(mStr)
sSave = Space(5000 * Length) 'make buffer for justified comparison
'Get the current tickcount
T = GetTickCount
Pos = 1
sSave = Space(5000 * Length)
For Cnt = 1 To 5000
Mid(sSave, Pos, Length) = mStr
Pos = Pos + Length
Next Cnt
'Show the results
MsgBox "It took Visual basic" + Str$(GetTickCount - T) + " msecs. to add 5000 times a string to itself."
'Get the current tickcount
T = GetTickCount
Pos = 0
sSave = Space(5000 * Length)
For Cnt = 1 To 5000
CopyMemory ByVal StrPtr(sSave) + Pos, ByVal StrPtr(mStr), LenB(mStr)
Pos = Pos + LenB(mStr)
Next Cnt
'Show the results
MsgBox "It took CopyMemory" + Str$(GetTickCount - T) + " msecs. to add 5000 times a string to itself."
End Sub