• 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

  • Recent Achievements

    • Conversation Starter
      DarkShrunken earned a badge
      Conversation Starter
    • One Month Later
      jrromero17 earned a badge
      One Month Later
    • Week One Done
      jrromero17 earned a badge
      Week One Done
    • Conversation Starter
      johnwin1 earned a badge
      Conversation Starter
    • One Month Later
      Marwin earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      250
    2. 2
      snowy owl
      157
    3. 3
      +FloatingFatMan
      140
    4. 4
      ATLien_0
      140
    5. 5
      Xenon
      128
  • Tell a friend

    Love Neowin? Tell a friend!