Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / March 2005

Tip: Looking for answers? Try searching our database.

Novice needs Array help.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steven M. Britton - 08 Mar 2005 04:13 GMT
I have a specialized program that exports data in a horrible text format,
that is some what consistent.  

I need to take the records of each line and split them out into columns.  I
am using a varString = Split(junkfield, ,6) - This is as far as I have gone
so far.  What is happening is that when I use the blank spaces and then
assign the varString to field values I get some blank values.  This is
because there are some records that have two or more spaces between data.  
Did I make sense or is more information required?

I need to know how to weed out the extra spaces so that I can bunch up the
data together.

Thanks,

-Steve
Dirk Goldgar - 08 Mar 2005 07:04 GMT
> I have a specialized program that exports data in a horrible text
> format, that is some what consistent.
[quoted text clipped - 13 lines]
>
> -Steve

Here's a function you can paste into a standard module and use in place
of the builtin Split() function for cases like this:

'----- start of code -----
Function SplitWords( _
           ByVal pstrSource As String, _
           Optional pstrDelim As String = " ", _
           Optional plngLimit As Long = -1, _
           Optional pCompare As Long = vbBinaryCompare) _
       As String()

   ' Split the argument pstrSource into an array of "words"
   ' based on the delimiter passed as pstrDelim, treating
   ' consecutive occurrences of the delimiter as a single
   ' occurrence.  So, for example, SplitWords("This   Function")
   ' returns the same output array as SplitWords("This Function").
   '
   ' Written by: Dirk Goldgar
   '             on: 8 March, 2005

   Dim strTwoDelim As String
   Dim lngLen As Long

   strTwoDelim = pstrDelim & pstrDelim

   Do
       lngLen = Len(pstrSource)
       pstrSource = Replace(pstrSource, strTwoDelim, pstrDelim, 1, -1,
pCompare)
   Loop Until Len(pstrSource) = lngLen

   SplitWords = Split(pstrSource, pstrDelim, plngLimit, pCompare)

End Function
'----- end of code -----

I just threw it together, but it seems to work.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Steven M. Britton - 09 Mar 2005 17:45 GMT
Thanks Dirk, it is perfect...

> > I have a specialized program that exports data in a horrible text
> > format, that is some what consistent.
[quoted text clipped - 51 lines]
>
> I just threw it together, but it seems to work.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.