[AccessD] Treat string as array

jwcolby jwcolby at colbyconsulting.com
Sun Mar 23 22:02:54 CDT 2008


ROTFL.  This is getting out of hand folks.  String to array, NOT string with
spaces in it.

Thanks though.

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 Max Wanadoo
Sent: Sunday, March 23, 2008 10:51 AM
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] Treat string as array

Public Function pfPadString()
  Dim iFor As Integer
  Dim strIn As String, strOut As String
  strIn = "Colby Consulting"
  For iFor = 1 To Len(strIn)
    strOut = strOut & Mid(strIn, iFor, 1) & " "
  Next iFor
  MsgBox strOut
End Function

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Gustav Brock
Sent: Sunday, March 23, 2008 9: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

>>> 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 


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list