|
-
Dec 4th, 2000, 02:39 PM
#1
Thread Starter
Member
I'm using VB4 and am trying to use a replacement function for VB6's split().
The error messaage I get is that I cannot assign to a non-byte array. In essense what I'm doing is:
Dim x(5)
x=Split("1/11/2000","/")
msgbox x(1)
Need any and all help,
Old Man
Using VB6 Professional Ediion
-
Dec 4th, 2000, 02:58 PM
#2
_______
<?>
You can't use VB6 functions in 4
Also, you don't declare the split variable as an array
It must be declared as a variant
Code:
'split function for VB5 and under vb6 has the function
'posted originally by Aaron Young
Public Function Split2(ByVal sString As String, ByVal sSeparator As String) As Variant
Dim sParts() As String
Dim lParts As Long
Dim lPos As Long
lPos = InStr(sString, sSeparator)
While lPos
ReDim Preserve sParts(lParts)
sParts(lParts) = Left(sString, lPos - 1)
sString = Mid(sString, lPos + Len(sSeparator))
lPos = InStr(sString, sSeparator)
lParts = lParts + 1
Wend
If Len(sString) Then
ReDim Preserve sParts(lParts)
sParts(lParts) = sString
End If
Split2 = IIf(lParts, sParts, Array())
End Function
'Example:
Private Sub Form_Load()
Dim x as string , y as Variant
x = "1999/12/12"
y = split2(x,"/")
End Sub
You should end up with
y(0) = 1999
y(1) = 12
y(2) = 12
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Dec 4th, 2000, 03:40 PM
#3
Thread Starter
Member
Thanks!
It works - as reported!!
Old Man
Using VB6 Professional Ediion
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|