Evil_Giraffe:
Am now investigating method you suggest and have some questions on proper way of coding, referencing and navigating the class library.
I have setup a simple main form in one project that does the following:
1. on form load, executes a function from the class library and displays the text.
2. on Button Click sends some text to the class library form text then displays the form from Class Library
3. Class Library Form has button to load another form within the same class library.
Please look at code below and let me know if I'm doing this correctly and if there's a better way to do it.
Your comments are appreciated.
Lee
Main Form Code:
Code:
Imports CommonClass
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Label1.Text = Class1.GetSomeText() ' get some text form function in Class1 of CommonClass Library
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim myform As New FormS1 'Do I need to Instantiate a form from the class?
myform.Text = "The Form" 'why not just formS1.text?
myform.Show()
End Sub
End Class
Class Library Code:
Code:
Public Class Class1
Public Shared myVariable As String = "Some Common Data Variable" 'is this the proper way to declare global variables
Public Shared Function GetSomeText() As String
Return "Text message"
End Function
End Class
Public Class FormS1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim locffrm As New CommonClass.LocalForm ' Here we're accessing a "Local" form within the class library
locffrm.Show() 'why not just LocalForm.show?
End Sub
End Class