vidhi Posted July 8, 2008 Posted July 8, 2008 Hi, I am migrating my vb6 project to vb.net. currently i have two forms and second form contains public function GetData , in VB6 i was calling this function from form1 as below str =Form2.GetData Form2 is the name of second form.. how can i do this u=in VB.net . Do not want to create object of Form2 in form1. help needed........... Quote
Administrators PlausiblyDamp Posted July 8, 2008 Administrators Posted July 8, 2008 http://www.xtremedotnettalk.com/showthread.php?t=83092 might be worth a quick look as it covers the basic differences between VB6 and .Net forms. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Nate Bross Posted July 8, 2008 Posted July 8, 2008 If you don't want to create an object of Form2 in Form1 but you need to call a method on that other object, you could do something like this using a Shared [static in C#] method: Class Form2 .... Public Shared Function GetData(....) ... End Function End Class Class Form1 ... Sub Form1_Load() Dim DataObject as Object DataObject = Form2.GetData(...) End Sub End Class This code will work regardless of if the Classes are Forms or any other type of class. However; as PD stated there are major differences between VB6 and .NET Forms, you should look at the post he provided. Quote ~Nate� ___________________________________________ Please use the [vb]/[cs] tags on posted code. Please post solutions you find somewhere else. Follow me on Twitter here.
cugone Posted July 8, 2008 Posted July 8, 2008 Define the Get Data Method as "Friend" then you can use it in the manner you already know. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.