Retrieve Value from existing form

muthu_pblr

New member
Joined
Jul 28, 2007
Messages
1
Programming Experience
1-3
Hi, Currently i am doing one windows based project. I have use two forms namely form1 and form2. while i am using this forms i just entered a value in form1. i want retrieve the form1 value into form2. how can i do this. please help me.

Thanks in Advance
Muthukumar
 
If you are launching form2 from form1 you can do this

VB.NET:
Public Sub LaunchForm2(Value as String)
   Dim newForm as new Form2
   newForm.Text = Value
   newForm.ShowDialog
   newForm.Dispose
End Sub

Replace the newForm.Text = Value to what you want to set in Form2.
 
Hi, Currently i am doing one windows based project. I have use two forms namely form1 and form2. while i am using this forms i just entered a value in form1. i want retrieve the form1 value into form2. how can i do this. please help me.

Thanks in Advance
Muthukumar


Make the variable a public property of Form1, then access it from form2's instance.. It all rather depends how Form1 came into existence actually, but a current list of all the forms that an app has open is available as a collection, in the My namespace, i think. Either My.Forms.Form1 or My.Application.OpenForms collection


http://msdn2.microsoft.com/en-us/library/87y2hdsf(VS.80).aspx


Actually, it always amazes me why people even ask this question, as though a form is something special or different to any other object in th application; it isnt!

If you want the length of a string, you access its LENGTH property:

myString.Length


myStrng is an object, your form is an object. If form2 wants to know something about form1, it has to ask just like asking a string how long it is:

form1.WhatverIWannaKnow


Thing is, you have to write the property code for WhateverIWannaKnow; maybe thats the part that confuses people.. Just write it and use it, like you would use any other property on any other object; its all the same thing
 
Probably arising from the (IMHO) retarded notion of making a public shared default instance of a form that has exactly the same name as the type of the form.. Yeah, creating objects and hiding the creation of them really helps programmers learn OO. Nice one Microsoft..

I think they might have ditched that practice in VB.NET, but you know.. I'm not actually sure!
 
Speaking of irritants with the Forms in VB.NET. One thing that got to me in the early stages was the that I couldn't launch a form hidden. I could set the opacity to 0%, which would then still have the app in the Alt-Tab menu. I believe it all spawned from the fact that the Visible property was removed for the Form properties.
 
Back
Top