Home General VB/VBA Copy Array
20 | 05 | 2012
This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade

Copy Array PDF Print E-mail
User Rating: / 0
PoorBest 
Tutorials
Written by Administrator   

Show/Hidden vbnet code

View source
 
 
	Public Sub CopyArray(FromArray As Variant, ToArray As Variant)
 
 
 
	'Copies source array to dest array
 
	'ToArray should be dynamic array
 
 
 
	Dim l As Long, lUBound As Long, lLBound As Long
 
 
 
	If (Not IsArray(FromArray)) Or (Not IsArray(ToArray)) Then Exit Sub
 
 
 
	lLBound = LBound(FromArray)
 
	lUBound = UBound(FromArray)
 
 
 
	ReDim ToArray(lLBound To lUBound)
 
	For l = lLBound To lUBound
 
	ToArray(l) = FromArray(l)
 
	Next
 
	End Sub
 
 
 
	Sub TestCopyArry()
 
 
 
	Dim i(2) As Integer, j() As Integer
 
	Dim iCtr As Integer
 
 
 
	i(0) = 5
 
	i(1) = 8
 
	i(2) = 10
 
	CopyArray i, j
 
	For iCtr = 0 To UBound(j)
 
	Debug.Print j(iCtr)
 
	Next
 
 
 
	End Sub

Attachments:
FileDescriptionFile sizeDownloads
Download this file (CopyArray.txt)CopyArray.txtCopy Array0.6 Kb229
 

Add comment


Security code
Refresh

This site has been updated and renewed. You have followed an old link.

Click here to go to the new site

http://www.visiblevisual.com/jupgrade