2 Replies - 997 Views - Last Post: 28 November 2009 - 07:51 AM Rate Topic: -----

#1 Matty919  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 10-May 09

Multiple form declarations

Posted 28 November 2009 - 07:25 AM

I have multiple forms and have multiple declarations that I need for all the forms, is there a better way than declaring them each time on each form? Can a .dll do this, if so does it require the .dll to be a seperate file than the final .exe file. Or is there someway to reference the variables on other forms?

Thanks.
Is This A Good Question/Topic? 0
  • +

Replies To: Multiple form declarations

#2 LeisureProgrammer  Icon User is offline

  • N00by VB.NET Developer
  • member icon

Reputation: 110
  • View blog
  • Posts: 588
  • Joined: 06-September 09

Re: Multiple form declarations

Posted 28 November 2009 - 07:43 AM

In your main form, when you're declaring variables, do it like this:
Put the declarations outside any subs, you don't have to populate them though.
Public Shared blah As String = "hello" 'You can change the type and value of the variable



At the very top of your other forms put something like this:

imports windowsapplication1.form1 'applicationname.mainform'sname



This will share the variables.

This post has been edited by LeisureProgrammer: 28 November 2009 - 07:49 AM

Was This Post Helpful? 1
  • +
  • -

#3 Matty919  Icon User is offline

  • D.I.C Head

Reputation: 1
  • View blog
  • Posts: 83
  • Joined: 10-May 09

Re: Multiple form declarations

Posted 28 November 2009 - 07:51 AM

View PostLeisureProgrammer, on 28 Nov, 2009 - 06:43 AM, said:

In your main form, when you're declaring variables, do it like this:
Put the declarations outside any subs, you don't have to populate them though.
Public Shared blah As String = "hello" 'You can change the type and value of the variable



At the very top of your other forms put something like this:

imports windowsapplication1.form1 'applicationname.mainform'sname



This will share the variables.


That makes sense thankyou, I just tested with subroutines and functions this works this way too. Never knew that.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1