hi guys havent been here for a while , im a fairly competent vb.net programer but have a problem think im just missing something ,im working on a fairly big project but im gonna keep this question small and simple .
if i have 2 forms amd one module the module contains a public var user1 = string
my first form has text box and button 2nd form a label and button
i enter text into text box press button form 1 closes form2 opens and label displays var contents i press button on form 2 form closes form 1 opens enter new text repeat the procudure and the label on form 2 still contains the information from the first time i ran the prog and wont change , its as if the var is locked? any ideads before i get more depressed.
thank you


form1 code

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        user1 = TextBox1.Text
    End Sub

form2 code

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label1.Text = user1

    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    End Sub


Module Module1
    Public user1 As String
End Module

Recommended Answers

All 4 Replies

See if this helps.

Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        If Not Module1.sUserKeptAsPermanent = Nothing Then
            Form2.Label1.Text = sUserKeptAsPermanent
            sUserKeptAsPermanent = TextBox1.Text
            Form2.Label1.Text = Module1.sUserKeptAsPermanent
        End If
    End Sub
End Class
Module Module1
    Public sUserKeptAsPermanent As String = Nothing
    Public user1 As String = Nothing
End Module

Basically, you set the String in the Module once and always load same String.
As for user1 String, not sure what it is needed for.

have tried what you sugessted to no avail , what has to happen when i enter text into textbox ie(vb) press button the text is stored in var user1 form2 opens and shows the text you entered on a label , now this works fine for one time only if i go back to form1 change the text entered ie(.net) press button it wont change on form2 it will still show vb?

I must have read your original post wrong, my apologies.

Since you are using Me.Hide in Form2 and not Me.Close, the Form2_Load event will only fire off the first time it loads, after that it hides and shows, does not reload.
You could use Me.Close or just set the value the Form2.Label right before showing Form2 again.

user1 = TextBox1.Text
        With Form2
            .Label1.Text = user1
        End With

now we'er talking sometimes its just the simplest of things thanks for all your help in this matter i can now rest peacefully at night

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.