jwcolby
jwcolby at colbyconsulting.com
Sun Mar 23 22:01:17 CDT 2008
The "wide spacing" was simply meant to represent characters in an array, not actual spaces between characters in a string. I want to change a string into an array of characters, that is all. In fact I had to get on with life and just did the Mid() thing, ugly as it is. It is all working just fine, I just prefer easy to use, easy to read code, and that whole mid() thing is just plain ugly and hard to read. For next iterators are easy to read and see the intention. John W. Colby Colby Consulting www.ColbyConsulting.com -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock Sent: Sunday, March 23, 2008 5:18 AM To: accessd at databaseadvisors.com Subject: Re: [AccessD] Treat string as array Hi John As for the wide spacing you could do: Public Function aTest(strA As String) As String Dim abytTest() As Byte Dim intChar As Integer Dim strOut As String abytTest = strA For intChar = LBound(abytTest) To UBound(abytTest) If abytTest(intChar) = 0 Then strOut = strOut & Space(1) Else strOut = strOut & Chr(abytTest(intChar)) End If Next aTest = RTrim(strOut) End Function But it isn't much simpler than using Mid: Public Function StringWide(strPrint As String) As String Dim strWide As String Dim intLen As Integer Dim intPos As Integer intLen = Len(strPrint) If intLen > 0 Then strWide = Space(intLen * 2 - 1) End If For intPos = 1 To intLen Mid(strWide, intPos * 2 - 1) = Mid(strPrint, intPos, 1) Next StringWide = strWide End Function /gustav