Click here to Skip to main content
15,884,629 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I have a question regarding vb.net and how to ..um how to use one variable to govern the entire application.
Ok ill break it down.
What I would like to know can I use for example:

VB
dim strMode as boolean = true
if strMode = true then 'use class test1
if strMode = false then 'use class test2

class test1
 ' this is where all the code will be for the design view
end class

class test2
 ' this is where all the code will be for the design view
end class

'as you can tell i don't have a vb.net editor with me


I know i can use this
VB
#if 0 then
  somthing will not happen here
#end if
 #if 1 then
 essagebox.show("Somthing happend")
#end if 


I know i can use other forms

VB
class test
sub do_somthing
 If bla = true then form2.show else form3.show : me.hide
end sub
end class

but that is not what i am after.
Is what is it possable?

on this computer i do not have VS 2010 installed, is there like a cloud version of VS 2010 or 2008? that would be cool.

Thanks
Posted
Comments
Maciej Los 3-Apr-12 14:55pm    
I'm not sure what you want to do... Can you write some more about your problem? Do you want to call class 1 or 2 depend on value of variable? You should clarify your problem...

1 solution

Unfortunately, I don't believe that you can. Unless if you made a second form or module that isn't ever visible and then just use form2.(variable name) = whatever and whatever = form2.(variable name). OR module1.(variable name) = whatever and whatever = module1.(variable name)
In form 2. Just declare a public variable. This would set the variable for form 2 and use it.
Public variable:

public variablename as integer
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900