I want to use the New function for an object with array of objects as parameters something like this -
Sub New(varPar () as Object)
End Sub
In my Class I have several objects that can be initialized.
I'm trying to make a the code general so the calling code will put in the varPar array the objects it wants to init and I will use something like this -
Dim obj1 as <type1>
Dim obj2 as <type2>
.
.
.
dim objN as <typeN>
Sub New(varPar () as Object)
if varPar is nothing then
return
end if
if varPar.Length > 0 then
obj1 = varPar(0)
if varPar.Length > 1 then
obj1 = varPar(1)
etc...
End Sub
I want to do that in a loop like this
Dim obj1 as <type1>
Dim obj2 as <type2>
.
.
.
dim objN as <typeN>
dim varArray() as object = { obj1,obj2,obj3.......objN}
Sub New(varPar () as Object)
if varPar is nothing then
return
end if
for i = 0 to varPar.Lentgh -1
varArray(i) = varPar(i)
next
End Sub
This will init the varArray but not obj1 obj2 obj3 etc.
Does anyone know how I can achieve this?
It is trivial in C, but in VB I don't know if it is possible or not.
Stuff like that works better now than ever, but not recommended. Considering you are asking the question on workstation CPU article, I wouldn't for that class of system.
Question
Ophir
Hi
I want to use the New function for an object with array of objects as parameters something like this -
Sub New(varPar () as Object)
End Sub
In my Class I have several objects that can be initialized.
I'm trying to make a the code general so the calling code will put in the varPar array the objects it wants to init and I will use something like this -
Dim obj1 as <type1>
Dim obj2 as <type2>
.
.
.
dim objN as <typeN>
Sub New(varPar () as Object)
if varPar is nothing then
return
end if
if varPar.Length > 0 then
obj1 = varPar(0)
if varPar.Length > 1 then
obj1 = varPar(1)
etc...
End Sub
I want to do that in a loop like this
Dim obj1 as <type1>
Dim obj2 as <type2>
.
.
.
dim objN as <typeN>
dim varArray() as object = { obj1,obj2,obj3.......objN}
Sub New(varPar () as Object)
if varPar is nothing then
return
end if
for i = 0 to varPar.Lentgh -1
varArray(i) = varPar(i)
next
End Sub
This will init the varArray but not obj1 obj2 obj3 etc.
Does anyone know how I can achieve this?
It is trivial in C, but in VB I don't know if it is possible or not.
Thanks
Link to comment
https://www.neowin.net/forum/topic/1367330-vbnet-how-do-i-use-pointers-to-pointers-if-even-possible/Share on other sites
3 answers to this question
Recommended Posts