Different arguments based on a boolean value

Hi Experts,

I have a routine in my application where i would like a different argument to be asked for depending on the boolean value.

If the boolean value = false  i would the the argument to be a variable structure (named VariableStructure)

if it =true then i would like the argument to be an ArrayList.

Would the only way around this be to make the argument type and object?

Cheers,

Tom
LVL 3
TommyTwoPintsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
RamuncikasConnect With a Mentor Commented:
I think the only option is Object type if you want to use only one variable.
Suppose you have to variable types of yours VarType1 and VarType2.

Dim myVar as object
If myBool = True Then
   myVar = new VarType1
   'any necessery steps here
Else
   myVar = new VarType2
   'any necessery steps here
End if

Then later in your code:

If TypeOf myVar is VarType1 then
 ...
Else
 ...
End if

That's what I can suggest you.
0
 
RamuncikasCommented:
What do you mean by "asked"? Do you need a user input?
0
 
TommyTwoPintsAuthor Commented:
Sorry about the terminology.

I mean; I would like the argument variable type to be different depending on the value of a public boolean variable.
0
All Courses

From novice to tech pro — start learning today.