Danny wrote:
HI
I am trying to do this:
array4 = split(astring,chr(9))
and it seems the array4 cannot be larger than 256
how can I get around this?
I am trying to read in a file and parse it line by line, but I cant just
import as there are more than 256 fields, so i have to read it in with code.
Thakns
The code below knows no bounds :-)
-- code start ---
Option Compare Database
Option Explicit
Sub TestSplit()
Const cstrTestString As String = "ab|cd|efg|hijk|lm|n|opq|rs|tu|vw|xyz"
Dim strArray() As String
Dim lngNumElements As Long
Dim strTemp As String
Dim i As Long
strTemp = strTok(cstrTestString, "|")
Do While Len(strTemp)
lngNumElements = lngNumElements + 1
ReDim Preserve strArray(1 To lngNumElements)
strArray(lngNumElements) = strTemp
strTemp = strTok()
Loop
For i = 1 To lngNumElements
Debug.Print i & ": " & strArray(i)
Next
End Sub
Function strTok(Optional pstrSrce As String, Optional pstrDelim As
String) As String
Static intstart As Integer, strSaveStr As String, strDelim As String
Dim intBegPos As Integer, intEndPos As Integer
Dim intLn As Integer
On Error GoTo StrTokError
' If first call, make a copy of the string.
If pstrSrce <> "" Then
intstart = 1
strSaveStr = pstrSrce
strDelim = pstrDelim
End If
intBegPos = intstart
intLn = Len(strSaveStr)
' Look for start of a token (character that isn't delimiter).
Do While intBegPos <= intLn And InStr(strDelim, Mid(strSaveStr,
intBegPos, 1)) <> 0
intBegPos = intBegPos + 1
Loop
' Test for token start found.
If intBegPos > intLn Then
strTok = ""
Exit Function
End If
' Find the end of the token.
intEndPos = intBegPos
Do While intEndPos <= intLn And InStr(strDelim, Mid(strSaveStr,
intEndPos, 1)) = 0
intEndPos = intEndPos + 1
Loop
strTok = Trim(Mid(strSaveStr, intBegPos, intEndPos - intBegPos))
If IsNull(pstrSrce) Then
strTok = ""
End If
' Set starting point for search for next token.
intstart = intEndPos
StrTokExit:
Exit Function
StrTokError:
Resume StrTokExit
End Function
--- code end ---
--
Error reading sig - A)bort R)etry I)nfluence with large hammer