[RESOLVED] Microsoft Scripting Runtime
Hi guys,
I'm trying to use the Split() method in a module and I'm receiving an error informing me the function is undefined. I've inlcuded the Scripting Runtime in the references to the project but it's not made a difference.
Any idea why this might be happening?
Thanks
Re: Microsoft Scripting Runtime
What version of Excel are you using?
Re: Microsoft Scripting Runtime
I fail to see what the FileSystemObject has to do with this error..
Split is a VBA function, and this error will be due to either "MISSING" references, unsupported by the version of the VBA application you are using, or failure to disambiguate your code..
To disambiguate you will need to determine which other reference you are using and proceed the Split() with the reference itself..
For Example
VB Code:
Dim MyStr() As String
MyStr = VBA.Split("Danny|M|King","|")
Debug.Print MyStr(0)
Debug.Print MyStr(1)
Debug.Print MyStr(2)
Re: Microsoft Scripting Runtime
It's Access, sorry should have specified that - Microsoft Access 97
Re: Microsoft Scripting Runtime
Type VBA followed by the . if this is not in the list then it is not supported..
As far as I remember Access 97 does not support Split (It's A 2k or above function)
Re: Microsoft Scripting Runtime
Thanks for the help - you're right, of course. Access 97 doesn't support Split.
Are there any other ways that a String can be "tokenized" using Access 97?
Re: Microsoft Scripting Runtime
You would be better off creating your own split function to perform a similar job something like..
VB Code:
Private Function SplitStr(pString As String, pDelim As String, rArr() As String) As Boolean
Dim strTemp As String
Dim i As Long
On Error GoTo ForcedExit
SplitStr = False
ReDim rArr(1 To 1)
Do While InStr(pString, pDelim) > 0
strTemp = Left(pString, InStr(pString, pDelim) - 1)
i = i + 1
ReDim Preserve rArr(1 To i)
rArr(i) = strTemp
pString = Mid(pString, InStr(pString, pDelim) + 1)
Loop
'there could be one more left so test and append if so
If Len(pString) > 0 Then
i = i + 1
ReDim Preserve rArr(1 To i)
rArr(i) = pString
End If
SplitStr = True
ForcedExit:
On Error GoTo 0
End Function
Sub test()
Dim MyStr() As String
If Not SplitStr("Danny|M|King", "|", MyStr()) Then Exit Sub
Debug.Print MyStr(1)
Debug.Print MyStr(2)
Debug.Print MyStr(3)
End Sub
Re: Microsoft Scripting Runtime
Guess it's time I requested a newer version of Access.
Thanks for all the help, especially that last piece of code!