DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   VB.NET (http://www.daniweb.com/forums/forum58.html)
-   -   passing values from a form to a dialog form (http://www.daniweb.com/forums/thread32022.html)

macupryk Sep 9th, 2005 1:18 pm
passing values from a form to a dialog form
 
I have declared the following variables in the form transoverride.vb

Dim Account_Name, PolicyNumber, TransCodeOrig, TransEffDate, Override_Action, Override_New_Renewal, Override_Transaction_Code, ModifiedDate, ModifiedUID, Plan_Year As String
Dim RowNum As Integer

The goal of this question is that I want to pass the above variables to a dialog form called edittransoverride.
Public Sub DoModify()

Dim dTable As DataTable = Me.DataGrid1.DataSource
Dim bm As BindingManagerBase = Me.DataGrid1.BindingContext(Me.DataGrid1.DataSource, Me.DataGrid1.DataMember)
Dim dRow As DataRow = CType(bm.Current, DataRowView).Row
Me.lbNumRec.Text = Me.DsTransOverride1.Tables(0).Rows.Count.ToString()
Dim cEditTransOverride As New EditTransOverride
cEditTransOverride.ShowDialog()
cEditTransOverride.Dispose()

Me.SqlDataAdapter1.Update(Me.DsTransOverride1)
Me.DsTransOverride1.Tables(0).Clear()
Me.SqlDataAdapter1.Fill(Me.DsTransOverride1)
Me.DataGrid1.Refresh()

End Sub



In the subroutine that belogs to transoverride.vb I assign them values before passing to the dialog form.
Private Sub highLightRow(ByVal sender As Object, ByVal e As MouseEventArgs)

Dim pt = New Point(e.X, e.Y)
Dim grd As DataGrid = CType(sender, DataGrid)
Dim hit As DataGrid.HitTestInfo = grd.HitTest(pt)


If hit.Type = grd.HitTestType.Cell Then
grd.CurrentCell = New DataGridCell(hit.Row, hit.Column)
RowNum = hit.Row
grd.Select(RowNum)
Account_Name = Convert.ToString(grd.Item(RowNum, 0))
PolicyNumber = Convert.ToString(grd.Item(RowNum, 1))
TransCodeOrig = Convert.ToString(grd.Item(RowNum, 2))
TransEffDate = Convert.ToString(grd.Item(RowNum, 3))
Override_Action = Convert.ToString(grd.Item(RowNum, 4))
Override_New_Renewal = Convert.ToString(grd.Item(RowNum, 5))
Override_Transaction_Code = Convert.ToString(grd.Item(RowNum, 6))
ModifiedUID = Convert.ToString(grd.Item(RowNum, 7))
ModifiedDate = Convert.ToString(grd.Item(RowNum, 8))
Plan_Year = Convert.ToString(grd.Item(RowNum, 9))
End If
End Sub


Now I must get these values in the load of the edittransoverride.vb dialog form.

Private Sub EditForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' Save old values

oldPolicyNumber = PolicyNumber
oldTransCode = TransCodeOrig
oldTransEffDate = TransEffDate

' Verify for Null fields
FillTextBox(txtAccountName, Account_Name)
FillTextBox(txtPolicyNumber, PolicyNumber)
FillTextBox(txtUserId, ModifiedUID)
dteEffDt.Text = TransEffDate.ToShortDateString()
dteEffDt.Value = TransEffDate.ToShortDateString()
FillTextBox(txtDate, ModifiedDate)
FillComboBox(cmbOriginalTransCode, TransCodeOrig)
FillComboBox(cmbOverrideAction, Override_Action)
FillComboBox(cmbOverrideNR, Override_New_Renewal)
FillComboBox(cmbOverrideTransactionCode, Override_Transaction_Code)
txtPlanYear.Text = Plan_Year
Me.lbRecNum.Text = RowNum

End Sub

How do I go about defining these variables so I can use them in my Load routine of the Dialog form.?

ac001 Aug 17th, 2009 10:03 pm
Re: passing values from a form to a dialog form
 
You can add a module to your project and declare your variables as Public variables in the module. You can then use those variables in both your form and dialog form.

arunkp Aug 18th, 2009 9:39 am
Re: passing values from a form to a dialog form
 
you can declare the variables as public
this way

public <variable name> as <type>

in some form consider form1

then in the other form you say

form1.<variablename>


All times are GMT -4. The time now is 5:44 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC