Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VB Split() to create an array with Access 97 1

Status
Not open for further replies.

corchard

Programmer
Jul 3, 2002
23
0
0
CA
I know the Split() function was introduced in VB6, but I'm wondering how I can get Access 97 to recognize/use it to turn a string into an array.

I have attermpted to change the References to address it, but from what I can see, the Reference: "Visual Basic for Applications" is the .dll I need to replace, but it is a reserved reference.

I'd prefer not to write a new custom split() function if I can get away with it.

Any Ideas?

Cheers,

C.
"Illegitimis non carborundum"
(don't let the b@st@rds get you down)
 
VBSplit not available in A97. You will probably have to roll your own. Robert Berman
Data Base consultant
Vulcan Software Services
thornmastr@yahoo.com
 
actually, ythere are several variations posted in these forumd. If 'search' is working, look for 'basSplit' in the various Ms. Access forums.

MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Thanks Everyone, I guess this is just another one for everyone to find.

I have made the function to do the job in the end.

---------------------------------------
[tt]
Public Function Split(str, delimeter)
Dim Cnt As Byte, plc As Long
plc = 0
Cnt = 0
'count occurances of delimeter
Do While InStr(plc + 1, str, delimeter) > 0
plc = InStr(plc + 1, str, delimeter)
Cnt = Cnt + 1
Loop
plc = Cnt + 1
Dim theArray() As Variant
ReDim theArray(plc)
Cnt = 1
Do While InStr(1, str, delimeter) > 0
'add everything before delimeter to array
theArray(Cnt) = Left(str, InStr(1, str, delimeter) - 1)
'add everything after delimeter to new string
str = Mid(str, (InStr(1, str, delimeter)) + Len(delimeter))
Cnt = Cnt + 1
'next if
Loop
'add remaining string to array
theArray(Cnt) = str
'return str as new array

Split = theArray

End Function
[/tt]
---------------------------------------

Called as any Split() function would be. "Illegitimis non carborundum"
(don't let the b@st@rds get you down)
 
The normal 'naming convention' would avoid the duplication of the names of other function, perhaps particuarlly those which exist in other versions of the laanguage. The use of names of existing functions will cause difficulties at some point -especially where the functionallity is well conceieved. In two specific instances it will raise errors: If it is imported (copy / paste) into the other version, or if it is used in the 'older' version and it is later 'updated' to the newer version. I generally use the prefix "bas" for UDF procedures to avoid these problems. MichaelRed
m.red@att.net

There is never time to do it right but there is always time to do it over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top