![]() |
FUNCTION TO COPY STRING ARRAY !!
Hi -
I am looking for a vba function, copyArray()of type String, that will take in one String array, and produce a copy of the input. Specs: (1)The function should be able to take in either 1D or 2D string array, and produce its copy. (2)If the input is just "" or vbNullString, the output should be the same as well. Any help will be appreciated! Thanks Jay Dean *** Sent via Developersdex http://www.developersdex.com *** |
FUNCTION TO COPY STRING ARRAY !!
Sub test()
Dim i As Long Dim arrString1(0 To 10) As String Dim arrString2() As String For i = 0 To 10 arrString1(i) = Chr(i + 65) Next i 'copy the array arrString2 = arrString1 For i = 0 To 10 MsgBox arrString2(i) Next i End Sub RBS "jay dean" wrote in message ... Hi - I am looking for a vba function, copyArray()of type String, that will take in one String array, and produce a copy of the input. Specs: (1)The function should be able to take in either 1D or 2D string array, and produce its copy. (2)If the input is just "" or vbNullString, the output should be the same as well. Any help will be appreciated! Thanks Jay Dean *** Sent via Developersdex http://www.developersdex.com *** |
FUNCTION TO COPY STRING ARRAY !!
On Sun, 19 Jul 2009 14:05:48 -0700, jay dean wrote:
Hi - I am looking for a vba function, copyArray()of type String, that will take in one String array, and produce a copy of the input. Specs: (1)The function should be able to take in either 1D or 2D string array, and produce its copy. (2)If the input is just "" or vbNullString, the output should be the same as well. Any help will be appreciated! Thanks Jay Dean *** Sent via Developersdex http://www.developersdex.com *** If your function argument is a variant, and it's output is a variant, you can just set the input equal to the output. e.g.: ========================== Function CopyStringArray(s1) CopyStringArray = s1 End Function ========================= If you need to, you can cycle through each element of the array to ensure it is of type String. You can also test to see if it is an array. --ron |
FUNCTION TO COPY STRING ARRAY !!
Thanks, Ron! I think using the variant datatype even though uses more
memory would suffice for this purpose. I am trying to keep loops to a minimum so your approach works well. Jay Dean *** Sent via Developersdex http://www.developersdex.com *** |
FUNCTION TO COPY STRING ARRAY !!
On Sun, 19 Jul 2009 19:55:53 -0700, jay dean wrote:
Thanks, Ron! I think using the variant datatype even though uses more memory would suffice for this purpose. I am trying to keep loops to a minimum so your approach works well. Jay Dean *** Sent via Developersdex http://www.developersdex.com *** Glad to help. Thanks for the feedback. --ron |
All times are GMT +1. The time now is 09:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com