how to pass value from one form to another in vb.net
  • how can i pass value from one form to another in vb.net
    i.e pass value from form1 to form2 in vb.net.
  • 1 Comment sorted by
  • Vote Up0Vote Down atirnaveedatirnaveed
    17.50 Karma Accepted Answer
    Hi gobal,
    you can create constructor or some method in second form with some parameter and when you creating object from 1st form pass the value to it just like this

    Form2

    Public Class Form2
        Dim ID As String = ""

        Sub PassParam(ByVal param As String)
            Me.ID = param
        End Sub

    End Class

    Form1

    Public Class Form1

        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim frm1 As Form2 = New Form2()
            frm1.PassParam("Hello World")
        End Sub
    End Class


    if u want to use one value in many other forms i suggest u that u can hold that value in app.config





Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Tagged

Popular Posts of the Week

Optimum Creative