[AccessD] Treat string as array

Gustav Brock Gustav at cactus.dk
Sun Mar 23 04:17:43 CDT 2008


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

>>> jwcolby at colbyconsulting.com 22-03-2008 22:57 >>>
Well yea.  Uhh... sure.   

I thought I was asking a syntax question.

Given strCompanyName Colby Consulting

I need an array of:

C o l b y  C o n s u l t i n g

It is exactly that piece that I do not know how to do elegantly.  Oh sure I
can do the Mid() function N times but that is inelegant.  I thought perhaps
there would be a single SomeKeyWord(strCompanyName) that would return an
array of the characters in the strCompanyName.  I really don't work with
arrays that much and so I am much less godly in that area.

John W. Colby
Colby Consulting
www.ColbyConsulting.com 





More information about the AccessD mailing list