私が理解しようとしてきた問題について、私はちょっと困惑しています。これが私が直面している私の問題です。CustomerFind.vb と CreateInvoice.vb の 2 つのクラスがあります。ユーザーは検索ボタンをクリックして、一番上にある別のフォームを開きます。ユーザーがその顧客を検索すると、結果が DataGridView に表示されます。次に、ユーザーはその顧客の行を選択し、[OK] をクリックします。その CustomersID を (CustomerFind.vb) から --> (CreateInvoice.vb) に送信する必要があります。CreateInvoice でその変数を取得したら、その変数を使用して関数に渡して、その顧客の詳細のテーブルを取得する必要があります...私がすでに持っているものについては、以下を参照してください...
これにより、CustomerFind.vb フォームが開きます...
Private Sub btnFindCustomer_Click(sender As System.Object, e As System.EventArgs) Handles btnFindCustomer.Click
Dim findCustomer As New CustomerFind
findCustomer.ShowDialog()
End Sub
ユーザーが顧客を選択すると、変数は他のクラスに渡されます...
Public Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
Dim intCustomerID As Integer = dgvSearchResults.SelectedRows(0).Cells(0).Value
CreateInvoice.CreateNewInvoice(intCustomerID)
End Sub
これは、私も変数を渡している CreateInvoice.vb のサブです...
Public Shared Sub CreateNewInvoice(ByVal intCustomerID As Integer)
'Datatable to hold returned results'
Dim oTable As DataTable
'Get the data that we need for the customer'
oTable = CustomerHelper.GetCustomer(intCustomerID)
txtFirstName.Text = IIf(oTable.Rows(0).Item("First_Name") Is DBNull.Value, "NA", oTable.Rows(0).Item("First_Name")))
txtLastName.Text = IIf(oTable.Rows(0).Item("Last_Name") Is DBNull.Value, "NA", oTable.Rows(0).Item("Last_Name"))
txtCity.Text = IIf(oTable.Rows(0).Item("City") Is DBNull.Value, "NA", oTable.Rows(0).Item("City"))
cboState.SelectedValue = IIf(oTable.Rows(0).Item("State") Is DBNull.Value, "NA", oTable.Rows(0).Item("State"))
txtAddress.Text = IIf(oTable.Rows(0).Item("Address") Is DBNull.Value, "NA", oTable.Rows(0).Item("Address"))
txtZipCode.Text = IIf(oTable.Rows(0).Item("Zip_Code") Is DBNull.Value, "NA", oTable.Rows(0).Item("Zip_Code"))
txtEmail.Text = IIf(oTable.Rows(0).Item("Email") Is DBNull.Value, "NA", oTable.Rows(0).Item("email"))
txtHomePhone.Text = IIf(oTable.Rows(0).Item("Home_Phone") Is DBNull.Value, "NA", oTable.Rows(0).Item("Home_Phone"))
txtCellPhone.Text = IIf(oTable.Rows(0).Item("Cell_Phone") Is DBNull.Value, "NA", oTable.Rows(0).Item("Cell_Phone"))
txtMiddleInitial.Text = IIf(oTable.Rows(0).Item("Middle_Initial") Is DBNull.Value, "NA", oTable.Rows(0).Item("Middle_Initial"))
End Sub
問題はここに依存しています。ALL OF THE TEXTFIELDS CANNOT REFER TO AN INSTANCE MEMBER OF A CLASS FROM WITHIN A SHARED METHOD... 返されたテーブルからこれらのフィールドに入力する必要があります。
ここで何が欠けているのかわかりません。たぶん疲れているだけです...
ありがとう!