I have a function that I'd like to have return info in an array. Is this possible or should I seperate each item and then split the items when the function info is recieved?
Thanks
code might be something like...
MsgBox UBound(GetInfo)
o]
function getinfo () as array?
ubound(getinfo)= hi
redim preserve getinfo(ubound(getinfo)+1)
Public Function ReturnArr() As String()
ReturnArr = Split("returns|an|array", "|")
End Function
That semi-confuses me...
function TheFunc() as string()
TheFunc(1) = "hi"
TheFunc(2) = "low"
end function
sub DoTheWork()
Dim Arr() as string
Arr()=TheFunc
end sub
Would that work?
Don't know.
Go stick it in an empty project and call it, and fix it accordingly. :)
Function TheFunc() As String()
Dim Arry(1) As String
Arry(0) = "Low"
Arry(1) = "High"
TheFunc = Arry
End Function
Sub DoTheWork()
MsgBox UBound(TheFunc)
End Sub
Its usually good pratice I think Not to use a function as a vareable...
The Above Code Works.
~-~(HDX)~-~
Thanks HdxBmx27, that worked like a charm...? :-*
Never call me by my full username -.- its annoying, Hdx, short, sweet, simple, my name over ALL my usernames, ever wonder why i have
|
V that? O and NP any other questions?
~-~(HDX)~-~
Quote from: HdxBmx27 on February 02, 2005, 06:38 PM
Function TheFunc() As String()
Dim Arry() As String
ReDim Arry(0 To 1)
Arry(0) = "Low"
Arry(1) = "High"
TheFunc = Arry
End Function
Sub DoTheWork()
MsgBox UBound(TheFunc)
End Sub
Its usually good pratice I think Not to use a function as a vareable...
The Above Code Works.
~-~(HDX)~-~
Why not just Dim Arry(0 to 1) As String?
Um iono, laziy coding, But maby cuz I wanted him to be avle to delete the lines below that and do it for himself.. But ya, mostly cuz i wrote it without looking at what i was dooing 0.o
~-~(HDX)~-~
Yeah, I just publicly declared an array, & then I redim it when needed.
Mucho thanks again HDX!
Quote from: CrAz3D on February 02, 2005, 10:35 PM
Yeah, I just publicly declared an array, & then I redim it when needed.
Mucho thanks again HDX!
Sounds costly, albeit it is Visual Basic.
Quote from: dxoigmn on February 02, 2005, 11:12 PM
Sounds costly, albeit it is Visual Basic.
True, I suggest that he simply has it a private Dim, jsut for that function so it dosent take up as much space, 0.o (MEM wise)
But ya it's vb, what cha gona do? And I cant learn C till Seinor year!!! and noone else but school is willing to teach>.<
~-~(HDX)~-~
It wouldn't be more work/space required to keep re-declaring it EVERYTIME I need it? ( about 5-6 times so far )
Quote from: CrAz3D on February 02, 2005, 11:58 PM
It wouldn't be more work/space required to keep re-declaring it EVERYTIME I need it? ( about 5-6 times so far )
Maybe this variable should be static then
Function TheFunc() As String()
Static Arry(0 To 1) As String
Arry(0) = "Low"
Arry(1) = "High"
TheFunc = Arry
End Function
Like that? Wouldn't that still be wasting time by stating whats in the variable?