I've been trying implement Constructor method in passing variable between two forms.
Just a rough user interface guide - issue Invoice. User would type in all the Customer Name, Document Number. Once he reached Item Details, a Child Form would pop-up for the User to select/search the Invoice's Item; Once selected, the selected item would showed in the primary Form.
What I had tried is, the Constructor method worked perfectly when it is self-contain in a new project, yet to be implement in my application.
But when I implemented, there is an error:
Reference to a non-shared member requires an object reference.
The error highlighted at my main (menu) form - where one of the menu selection referred to the Invoice Form.
Constructor Code at the Invoice Form
Expand|Select|Wrap|Line Numbers
- Public Sub New(ByVal strTextBox As String)
- InitializeComponent()
- txtPartNumber.Text = strTextBox
- End Sub
Expand|Select|Wrap|Line Numbers
- Private Sub passVariableNextForm()
- Dim frm As NewStockTransaction = New NewStockTransaction(selectedBox.Text)
- frm.Show()
- Me.Dispose()
- End Sub
- Private Sub btnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSend.Click
- passVariableNextForm()
- End Sub
Imports System.Data
Imports System.Data.SqlClient