How to pass form data to another form?

seahck

Member
Joined
Jul 12, 2004
Messages
6
Programming Experience
Beginner
How to pass form data to another form?
i have 2 form, form1 and form2 and how can i pass a value that i select in data grid on form1 to a textbox on form2?
 
try this one:
VB.NET:
  'in your form1 instantiate the form2
  dim d as new form2
  'in the datagrid click events
  d.TextBox1.Text = DataGrid1.Item(DataGrid1.CurrentCell.RowNumber, DataGrid1.CurrentCell.ColumnNumber)

hope this helps..
 
add a module to your project and declare public variables in it. Those variable will be accessible throughout the project.
 
rhinton said:
add a module to your project and declare public variables in it. Those variable will be accessible throughout the project.
declare application wide variables as Friend, not Public public shares yer variable system wide (can be accessed by completely seperate programs) whereas Friend keeps it to your app only

use friend instead of public
 
i still dun know how to do it ..

may be i should make my question more clearly ...

i have
Form1 , Form2
Dg1, Dg2


now .. i add a new Purchase Order in Form1 ..
Dg1 show a new Purchase order with Blank Record...

Then

i search the Item in Form2
Dg2 show all items ...

then

i select a Row(an item)in Dg2 then press Add or Double click it

then

Selected item will pass to Dg1

Finally

i pass Confirm to save the Purchase Order

could you guys teach me how to achieve stuff above ...
please help ... i need this function so much .. !!
 
a simple way to do so is to declare this at the top:

public shared username as string


then in the open new form code:

user = txtUser.Text
Try

Dim currentform = New frmAccess

currentform.Show()

Catch ex As Exception

MessageBox.Show(ex.Message())

End Try



then on the new form load code:

lblUser.Text = ("User: " & frmLogin.user)
 
Back
Top