Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

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
0
TommyTwoPints
Asked:
TommyTwoPints
  • 2
1 Solution
 
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
 
RamuncikasCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now