Hello,
I am trying to write a function that returns two values but I can't
figure out the syntax or if it's even possible.
Private Function CTXScanner(ByVal mfSvr As String, ByVal xmlstr
As String, ByVal xslstr As String)
Try
For Each HotfixItem In MFRecHotfix.Items
xmlstr = xmlstr & "<MFHOTFIX ID=""" &
HotfixItem & """>" & Environment.NewLine
xmlstr = xmlstr & "<SERVER>" & mfSvr &
"</SERVER>" & Environment.NewLine
xmlstr = xmlstr & "</MFHOTFIX>"
Next
Return xmlstr
Return xslstr
End If
srv2 = Nothing
winSrv2 = Nothing
Catch ex As Exception
MsgBox(ex.Message.ToString())
Exit Function
End Try
End Function
Jon Skeet [C# MVP] - 30 Mar 2006 20:39 GMT
> I am trying to write a function that returns two values but I can't
> figure out the syntax or if it's even possible.
It's not - at least, you can't have two actual return values. However,
you *can* use out parameters to simulate multiple return values.
Personally, I'd suggest splitting the function into two - one for the
XML and one for the XSL.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Ken Halter - 31 Mar 2006 00:27 GMT
> Hello,
>
[quoted text clipped - 3 lines]
> Private Function CTXScanner(ByVal mfSvr As String, ByVal xmlstr
> As String, ByVal xslstr As String)
No real help here... just noting the lack of a return type.
As far as multiple returns goes, in VB6, I can return arrays, collections,
classes, etc. So, if you create a class to hold your returns, you're set...
arrays and collections are Ok too but, since I'm a "VB6'er", collections
aren't really type safe (they can be but.....) I like using a class so I can
have my type/range checking, etc. with intellisense.

Signature
Ken Halter - MS-MVP-VB (visiting from VB6 world) - http://www.vbsight.com
Please keep all discussions in the groups..
Charles Law - 31 Mar 2006 09:38 GMT
Hi Brian
In addition to the other answers, as you are returning state and not
function, you might want to use a structure rather than a class to return
your two values.
HTH
Charles
> Hello,
>
[quoted text clipped - 24 lines]
>
> End Function
Cor Ligthert [MVP] - 31 Mar 2006 09:58 GMT
Brian,
You can return an array from the type "object".
I hope this helps,
Cor
Brian Cahill - 31 Mar 2006 16:07 GMT
I was mistaken in how I was handling Functions and Subs. I passed
ByRef instead of ByVal and now I'm alright. Thanks for the info though.