Solved

Different arguments based on a boolean value

Posted on 2006-07-13
3
210 Views
Last Modified: 2010-04-23
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
Comment
Question by:TommyTwoPints
  • 2
3 Comments
 
LVL 14

Expert Comment

by:Ramuncikas
ID: 17097379
What do you mean by "asked"? Do you need a user input?
0
 
LVL 3

Author Comment

by:TommyTwoPints
ID: 17097401
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
 
LVL 14

Accepted Solution

by:
Ramuncikas earned 500 total points
ID: 17097438
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

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question