DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: calling the methid from another form

  1. #1
    Join Date
    May 2006
    Posts
    45

    calling the methid from another form

    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...........

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    You can do the same thing in .NET.

    This worked just fine for me
    Code:
    Public Class Form2
        Public Function TestIt(ByVal strString As String) As String
            If strString = "Hello" Then
                MessageBox.Show("I got called from form1")
            End If
        End Function
    
    End Class
    
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Form2.TestIt("Hello")
        End Sub
    End Class

  3. #3
    Join Date
    May 2006
    Posts
    45
    But I am getting the error Reference to a non-shared member requires an object reference.

  4. #4
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,663
    What is the code that you are using?

  5. #5
    Join Date
    Dec 2004
    Posts
    163
    Vidhi,

    What version of vb.net are you using?

    Kerry Moorman

Similar Threads

  1. calling a C# Windows Form from C++
    By redjoy in forum .NET
    Replies: 1
    Last Post: 05-08-2006, 03:22 PM
  2. Replies: 0
    Last Post: 12-08-2001, 03:36 AM
  3. Setting form as MDIChild form at runtime
    By Setya in forum VB Classic
    Replies: 4
    Last Post: 01-09-2001, 04:57 AM
  4. Setting form as MDIChild form at runtime
    By Setya in forum VB Classic
    Replies: 0
    Last Post: 01-08-2001, 06:53 AM
  5. I am helpless - Edit Info form
    By Dan in forum VB Classic
    Replies: 0
    Last Post: 03-17-2000, 06:14 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center