How to retrieve the value from one form to another in vb.net

I have the problem to retreive the string from one form to another. here is my code: What's wrong with this?

Public Class Form3

    Dim unit As String

    Public itmname As String
 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim obj1 As New Form4
        itmname = tb1.Text
        MessageBox.Show(itmname)
        obj1.Label1.Text = itmname
        obj1.Show()

    End Sub
End Class
Public Class Form4
 Private Sub Form4_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        With Form3
            MessageBox.Show("item name:" + .itmname)
           Label1.Text = .itmname
        End With
    End Sub
End Class

Answers


You shouldn't have to do any special code in Form4 to set the value. you already set the textbox value from from3's button click event. Setting again is just overwriting it with a blank value from a newly instantiated form. Just clear all the code you have listed in Form4's load event and it should work.


Need Your Help

Changing to OK on form in Windows CE .NET 4.2 in .NET application

.net windows-mobile windows-ce

I have a .NET application that is being targeted to run on Windows Mobile 5 and Windows CE .NET 4.2 and there are some minor differences between how forms display that I'm trying to converge.

Using or in python

python syntax

New to coding, having problems making foolproof input for program:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.