|
-
Aug 13th, 2002, 05:52 PM
#1
Thread Starter
New Member
ByRef Error
I am getting an error when trying to pass a Split directly to another function.
This is the Add function - It is in a class module:
Code:
Public Sub Add(strItem As String)
If Arr(0) <> "" Then
'Redimension Array
ReDim Preserve Arr(UBound(Arr) + 1)
End If
'Add channel to end of array
Arr(UBound(Arr)) = strItem
End Sub
From another module, I want to do this:
Code:
TheBot.Prop_Controllers.Add Split(Parameter," ")(1)
However, this gives me a ByRef error. I can fix this by doing this:
Code:
Dim mysplit As String
mysplit = Split(Parameter, " ")(1)
TheBot.Prop_Controllers.Add mysplit
But seeing as I use that statement many times in the same module, I would rather not double my sourcecode size. Is there any way to get around this error without using a lot of extra code? Maybe a C-Style static cast?
Any help would be appreciated!
DocUK
-
Aug 13th, 2002, 06:00 PM
#2
Fanatic Member
Try this:
VB Code:
'This way will pass the result of the split as a string.
TheBot.Prop_Controllers.Add cstr(Split(Parameter," ")(1))
VB Code:
'Or change your procedure to accept the parameter ByVal like this:
Public Sub Add(ByVal strItem As String)
If Arr(0) <> "" Then
'Redimension Array
ReDim Preserve Arr(UBound(Arr) + 1)
End If
'Add channel to end of array
Arr(UBound(Arr)) = strItem
End Sub
Either method should fix you up. I'd Prefer the ByVal Option if it was me.
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Aug 13th, 2002, 06:09 PM
#3
Thread Starter
New Member
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
|