Тип данных такой:
- Код: Выделить всё
Type MyType
F As Boolean
T As String
....
End Type
Вопрос наверно, примитивный, но я раньше с этим не сталкивался.
Возможно прийдется использовать CopyMemory?
Type MyType
F As Boolean
T As String
....
End Type
Copymemory arr1(0), byval arr2(0), byval UBound(arr1)
Aleksej писал(а):Попробуй так:
- Код: Выделить всё
Copymemory arr1(0), byval arr2(0), byval UBound(arr1)
Private Sub Form_Load()
Dim a() As Long
ReDim a(4)
MsgBox UBound(a) - LBound(a) + 1 '5
End Sub
Dim arr1() As ...
Dim arr2() As ...
Copymemory arr1(0), arr2(0),( UBound(arr1) - LBound(arr1) + 1 ) * Lenb(arr1(0))
X-BOND писал(а):Не работает![]()
Кстати, размер массива фиксирован (128)
Пример реально работающий есть?
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
Private Sub Form_Load()
Dim arr1() As Long
Dim arr2() As Long
ReDim arr1(5)
ReDim arr2(5)
arr2(2) = 3
CopyMemory arr1(0), arr2(0), (UBound(arr1) - LBound(arr1) + 1) * LenB(arr1(0))
Print arr1(2) '3
End Sub
Dim Arr(0 to 128) as MyType
Dim Cop(0 to 128) as MyType
CopyMemory Cop(0).F, ByVal Arr(0).F, UBound(Cop().F)
CopyMemory Cop(0).V, ByVal Arr(0).V, UBound(Cop().V)
....
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Declare Function GetTickCount Lib "kernel32" () As Long
Private Sub Form_Load()
'KPD-Team 1999
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
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
Сейчас этот форум просматривают: Yandex-бот и гости: 4