• 0

[VB6] Sharing A Variable Between Forms


Question

I've got a program with multiple forms in VB6 and I want to share the contents of a text box on one form with another form. I did a search and it seems like a I have to use a public property but I can't get it to work.

What do I need to put in the Let and Get procedure, and how do I assign the value of the text box to the variable and call the variable in the other form?

Thanks.

Link to comment
https://www.neowin.net/forum/topic/285645-vb6-sharing-a-variable-between-forms/
Share on other sites

9 answers to this question

Recommended Posts

  • 0
  blobblob said:
I've got a program with multiple forms in VB6 and I want to share the contents of a text box on one form with another form. I did a search and it seems like a I have to use a public property but I can't get it to work.

What do I need to put in the Let and Get procedure, and how do I assign the value of the text box to the variable and  call the variable in the other form?

Thanks.

585476931[/snapback]

Don't you need a global variable? Or is there a better way?

Also you might be able to point to the textbox if it stays in memory. (frmName.txtbox)

I'm not much good in VB but I remember a little from college.

  • 0

Well like you said you use the public property

Public thingy as String

To call it from the other form just prefix everything you do with the forms name

So if you were on Form2 and wanted to assign and call the variable you would go

Form1.thingy = Form1.textbox.text
msgbox Form1.thingy

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • Oh no... here we go again. Tha same sh*t that happaned to Mail & Calendar...
    • I too have worked with pro gear for decades and so I found the interface to be unintuitive from both the pro and casual side (a rare "accomplishment" by what are obviously otherwise skilled coders, hehe). I eventually got it to work, thanks for offering, but I found other compatibility issues with my own use case, so I just dropped it entirely. Right now, I just use an analog line out/line in approach which works as expected across all usage scenarios. With both machines on the same power block/outlet, I'm not getting any analog hum or hiss. My next step will be to try the updated Multiplicity 4 when a bug, addressing this very issue unfortunately, is resolved. Knowing Stardock, that could be tomorrow or five years from now, so I check back every few months to see it it's fixed and I want to upgrade. Again, thanks for offering to help.
    • We recognize that performance can use some improvements, and we continue to work on improving it. However, it's worth noting that massive performance improvements don't happen overnight, they take a lot of work and effort, and in most cases, the improvements are more noticeable when you compare across several updates. That said, Files is open-source and everyone is invited to help with these efforts 🙂
    • A lot of effort has gone into improving stability and Files Preview now has a 99% crash free rate. These improvements will make their way to Files Stable when v4 is released later this year. If you're still experiencing issues, please report them on GitHub or Discord so we can track them properly.
  • Recent Achievements

    • Rookie
      Snake Doc went up a rank
      Rookie
    • First Post
      nobody9 earned a badge
      First Post
    • One Month Later
      Ricky Chan earned a badge
      One Month Later
    • First Post
      leoniDAM earned a badge
      First Post
    • Reacting Well
      Ian_ earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      495
    2. 2
      Michael Scrip
      203
    3. 3
      ATLien_0
      197
    4. 4
      Xenon
      137
    5. 5
      +FloatingFatMan
      115
  • Tell a friend

    Love Neowin? Tell a friend!