The new forums will be named Coin Return (based on the most recent vote)! You can check on the status and timeline of the transition to the new forums here.
The Guiding Principles and New Rules document is now in effect.

Global variables and Visual Basic 6

IriahIriah Registered User regular
edited June 2007 in Help / Advice Forum
I've up until now declared globals in my first form. I realised just recently I needed to use a global from my first form in my second form, only it won't reference it when I try GlobalName(0).Blahblah or Form1.GlobalName(0).Blahblah. I also tried declaring it in a module, but there's no dice there.

So how can I make these global variables more global?

Iriah on

Posts

  • MKRMKR Registered User regular
    edited June 2007
    Is it absolutely necessary that it be done in VB6? VB.NET express is free, and is infinitely better than 6.

    http://www.dreamincode.net/forums/showtopic10415.htm

    In VB.NET you would just make a new class and add a property.

    This is C#, but the only difference between it and VB.net is some of the syntax:
    private int myVar;
    
            public int MyProperty
            {
                get { return myVar; }
                set { myVar = value; }
            }
    

    MKR on
  • IriahIriah Registered User regular
    edited June 2007
    MKR wrote: »
    Is it absolutely necessary that it be done in VB6? VB.NET express is free, and is infinitely better than 6.

    http://www.dreamincode.net/forums/showtopic10415.htm

    In VB.NET you would just make a new class and add a property.

    This is C#, but the only difference between it and VB.net is some of the syntax:
    private int myVar;
    
            public int MyProperty
            {
                get { return myVar; }
                set { myVar = value; }
            }
    

    Unfortunately, yes. Our school, in its infinite wisdom, has seen fit to base the marking wholly on a program we code in VB6, the whole of VB6, and nothing but VB6.

    Iriah on
  • MKRMKR Registered User regular
    edited June 2007
    Iriah wrote: »
    MKR wrote: »
    Is it absolutely necessary that it be done in VB6? VB.NET express is free, and is infinitely better than 6.

    http://www.dreamincode.net/forums/showtopic10415.htm

    In VB.NET you would just make a new class and add a property.

    This is C#, but the only difference between it and VB.net is some of the syntax:
    private int myVar;
    
            public int MyProperty
            {
                get { return myVar; }
                set { myVar = value; }
            }
    

    Unfortunately, yes. Our school, in its infinite wisdom, has seen fit to base the marking wholly on a program we code in VB6, the whole of VB6, and nothing but VB6.

    :(

    In that case, I think VB6 has classes and properties too. It has been too long since I touched 6 for me to remember, but google should help.

    MKR on
  • romanqwertyromanqwerty Registered User regular
    edited June 2007
    Umm im not familliar at all with vb6 but i know some object orientated stuff. Do you have a reference from ur second form to ur first form
    eg.

    me.MdiParent?

    if so, just make the global variable a property of the first form and reference it like,

    int x = me.MdiParent.GlobalVariable?



    thats just a suggestion, i have no idea if it will do anything in vb6 and im almost certain the syntax is pretty wrong.

    romanqwerty on
  • IriahIriah Registered User regular
    edited June 2007
    Unfortunately I don't really know what you mean, I'm fairly new at this (oh, and the only time we were ever taught how to code in VB was two years ago by someone who didn't actually know how themselves).

    Cursed VB6! A pox on you!

    Iriah on
  • blincolnblincoln Registered User regular
    edited June 2007
    Are both forms going to be open at the same time? If they're not, ideally you'd want to pass the variable from the first form to the second when the second is created/opened.

    blincoln on
    Legacy of Kain: The Lost Worlds
    http://www.thelostworlds.net/
Sign In or Register to comment.