2

My problem is that I have two forms, Form1 and Form2 ...on Form1 there is a TextBox called txtTotal (this contains the calculation of Ticket Prices, thus it's a numeric value) and on Form2 there is a TextBox called txtTotal2. All I want to do is get the same number that appears in txtTotal on Form1 to appear in txtTotal2 on Form2

However whenever I try some of the help tips online such as using a declaring txtTotal as global or friend it dosn't work, and any other code iv tried attempts pass the textbox value as String which brings an error.

Any help wld be much appreciated :)

1
  • 2
    Show us what you've tried and what's wrong with it, and we'll show you how to fix it. Commented May 1, 2012 at 16:11

2 Answers 2

1

Form2 should either have public properties for the integer values that need to be passed, or take those values in it's constructor, then form1, when creating form2, will set those values, and then show the form.

Sign up to request clarification or add additional context in comments.

Comments

0

designer snapshot

form1 code:

Public Class Form1
    Public x As String = "msg from form2"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Form2.Show()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form2.TextBox1.Text = Me.TextBox1.Text
        TextBox2.Text = Form2.x
    End Sub
End Class

form2 code:

Public Class Form2
    Public x As String = "msg from form1"
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Form1.TextBox1.Text = Me.TextBox1.Text
        TextBox2.Text = Form1.x
    End Sub

End Class

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.