passing values from a form to a dialog form

Please support our VB.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2005
Posts: 4
Reputation: macupryk is an unknown quantity at this point 
Solved Threads: 0
macupryk macupryk is offline Offline
Newbie Poster

passing values from a form to a dialog form

 
0
  #1
Sep 9th, 2005
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.?
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 4
Reputation: ac001 is an unknown quantity at this point 
Solved Threads: 0
ac001 ac001 is offline Offline
Newbie Poster

Re: passing values from a form to a dialog form

 
0
  #2
Aug 17th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 11
Reputation: arunkp is an unknown quantity at this point 
Solved Threads: 0
arunkp arunkp is offline Offline
Newbie Poster

Re: passing values from a form to a dialog form

 
0
  #3
Aug 18th, 2009
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>
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC