Gustav Brock
Gustav at cactus.dk
Tue Mar 25 02:42:11 CDT 2008
Hi A.D. Very creative solution! For how long time will JC chew on this dry stick? Next step is probably that the spaces he specified originally which should not be present should be present anyway or perhaps replaced by a tab or a white space! Lots of options out there ... /gustav >>> adtp at airtelmail.in 25-03-2008 08:06 >>> A very concise version of Function Fn_ConvStringToArray(), using only a single statement, is placed below. It returns an array, so that individual characters of input string get placed in individual elements of the array. Note - In fact, right side of assignment statement (A) below, can be used directly, as it is made up purely of access built-in functions. Fn_ConvStringToArray() acts merely as a wrapper function, for sake of convenience. A.D.Tejpal ------------ ' Code to be placed in VBA module '================================ Function Fn_ConvStringToArray(StrInput _ As String) As Variant Fn_ConvStringToArray = _ Split(Format(StrInput, _ Mid(Replace(String(Len(StrInput), _ "~"), "~", "~@"), 2)), "~") ' (A) End Function '================================ ----- Original Message ----- From: A.D.Tejpal To: Access Developers discussion and problem solving Cc: A.D.Tejpal Sent: Tuesday, March 25, 2008 11:01 Subject: Re: [AccessD] Treat string as array Function Fn_ConvStringToArray(), as given below, returns an array, so that individual characters of input string get placed in individual elements of the array. Note - The three line block of code involving For/Next loop could have been replaced by a single statement using String() function. However, String() function recognizes only one character as its last argument. A.D.Tejpal ------------ ' Code to be placed in VBA module '============================= Function Fn_ConvStringToArray(StrInput _ As String) As Variant Dim Fmt As String, Cnt As Long For Cnt = 1 To Len(StrInput) Fmt = Fmt & "~@" Next ' Strip leading ~ Fmt = Mid(Fmt, 2) Fn_ConvStringToArray = _ Split(Format(StrInput, Fmt), "~") End Function '=============================