I've recently switched from using VB6 to C#.
To be honest, I'm not sure if I shouldn't go back because it seems more complicated and less quick then VB6. But I want to give it a fair chance.
Up until now, I've been programming software for controlling a specific graphics engine, using it's API.
In VB6, I would have a module where I would put all of my global variables and where I would initialize them. See the example below which only has a few statements:
Expand|Select|Wrap|Line Numbers
- global Engine as new xpEngine
- global MyScene1 as xpScene
- global MyScene2 as xpScene
- global Obj as xpBaseObject
- global TxtObj as xpTextObject
- public sub InitApplication
- engine.getSceneByName "Scene1", MyScene1
- engine.getSceneByName "Scene2", MyScene2
- end sub
So in my Main form I could use the following syntax pretty much everywhere.
Expand|Select|Wrap|Line Numbers
- MyScene1.getObjectByName "Textfield1", TxtObj
- TxtObj.Text = "Text to be put in the first textfield"
- MyScene1.getObjectByName "Textfield2", TxtObj
- TxtObj.Text = "Text to be put in the second textfield"
I can't declare anything as a global variable anymore.
But does this mean that I have to link every Scene in my application to the variable MyScene1 everytime I want to use it?
Also in VB6 when I started a new project, I just had to import my module in my project to start programming. It was very useful. It appears that in C# I will have to write time and time again?
Am I missing something? Or is there a way to make it easier for me?
Any help is appreciated.
Cheers,
Kenneth