473,320 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

pass a value from a text box to another in a diffrent form

Hello All!

I have been trying to figure this out, have recieved alot of help, but it's
just not clicking in the ol' noggin. I basicly have a value in a text box, I
need to keep that value and pass it on to another textbox on another form.
I understand that there is a couple of ways of doing this, one by using a
public class. The other by a public property. Here is my feeble attempt.
Public Class FormA
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public x As Integer
Public y As String = TextBox1.text
Private Sub FormA_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim secondForm As New FormB
secondForm.Show()
secondForm.getForm1(Me)

End Sub
End Class

Public Class FormB
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private Sub FormB_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub
Public Sub getForm1(ByVal theform As FormA)
theform.x = 6
theform.y = TextBoxB.Text

End Sub

End Class

I'm not sure where I'm going wrong on this. I feel I'm pretty close, just
missing something.
TIA!!

Rudy
Sep 17 '06 #1
2 1585

"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
Hello All!

I have been trying to figure this out, have recieved alot of help, but
it's
just not clicking in the ol' noggin. I basicly have a value in a text
box, I
need to keep that value and pass it on to another textbox on another form.
I understand that there is a couple of ways of doing this, one by using a
public class. The other by a public property. Here is my feeble attempt.
Public Class FormA
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public x As Integer
Public y As String = TextBox1.text
Private Sub FormA_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim secondForm As New FormB
secondForm.Show()
secondForm.getForm1(Me)

End Sub
End Class

Public Class FormB
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private Sub FormB_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub
Public Sub getForm1(ByVal theform As FormA)
theform.x = 6
theform.y = TextBoxB.Text

End Sub

End Class

I'm not sure where I'm going wrong on this. I feel I'm pretty close, just
missing something.
TIA!!

Rudy
Sorry Rudy, Its not clear what you are trying to do from this code.
Could you give a short Spec of the required flow and a description of what
it is not doing.
Currently the code is attempting to place the values from FormB back into
FormA fields as soon as it is instantiated. I would guess at this time it
would be empty as it has only just painted on the screen. I assume this is
not what you want to do.

If this is what you wanted to do then you should probably code it as
theform.y.Text = TextBoxB.Text.
If you are trying to pull a value from FormA into FormB then you need to
code something like this in FormB

Public Sub getForm1(ByVal theform As FormA)

TextBoxB.Text = theform.TextBox1.Text

End Sub


Sep 17 '06 #2
Hey Chris!!
That's funny, I'm not sure what I'm trying to do with this code either!. LOL!

Buy I am trying to pull a value from FormA into FormB. Your last suggestion
did the trick, I just had to change that last line you put in.

Thanks alot!

Rudy

"ChrisRM" wrote:
>
"Rudy" <Ru**@discussions.microsoft.comwrote in message
news:51**********************************@microsof t.com...
Hello All!

I have been trying to figure this out, have recieved alot of help, but
it's
just not clicking in the ol' noggin. I basicly have a value in a text
box, I
need to keep that value and pass it on to another textbox on another form.
I understand that there is a couple of ways of doing this, one by using a
public class. The other by a public property. Here is my feeble attempt.
Public Class FormA
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public x As Integer
Public y As String = TextBox1.text
Private Sub FormA_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim secondForm As New FormB
secondForm.Show()
secondForm.getForm1(Me)

End Sub
End Class

Public Class FormB
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Private Sub FormB_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

End Sub
Public Sub getForm1(ByVal theform As FormA)
theform.x = 6
theform.y = TextBoxB.Text

End Sub

End Class

I'm not sure where I'm going wrong on this. I feel I'm pretty close, just
missing something.
TIA!!

Rudy

Sorry Rudy, Its not clear what you are trying to do from this code.
Could you give a short Spec of the required flow and a description of what
it is not doing.
Currently the code is attempting to place the values from FormB back into
FormA fields as soon as it is instantiated. I would guess at this time it
would be empty as it has only just painted on the screen. I assume this is
not what you want to do.

If this is what you wanted to do then you should probably code it as
theform.y.Text = TextBoxB.Text.
If you are trying to pull a value from FormA into FormB then you need to
code something like this in FormB

Public Sub getForm1(ByVal theform As FormA)

TextBoxB.Text = theform.TextBox1.Text

End Sub


Sep 17 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: jeremylim2000 | last post by:
Hi! For Example, text for Product code, name (both is text) is from form A and I want pass the Product Code, and name to form B using eg. session('txtproduct') & session('txtname'). As in...
4
by: GavMc | last post by:
Hello I am new to internet programming and wonder if anyone can help me with this.... I am trying to pass a hidden field value on a form into another field on the form so that it can then be...
2
by: c676228 | last post by:
Hi, This is my first time to post asp.net question on this forum. I have a question for "How to pass the first form value to the next form" I have enrollinfo.aspx form which look like as follow:...
7
by: Rudy | last post by:
Hello All! I have a value in a textbox(txbTableIDm.Text ) that I would like to use in a paremiter in a SP I wrote, and then have the select statement work off that parememter, retireive a...
1
by: colleen1980 | last post by:
Hi: Can any one please tell me that how to i pass the two textbox values in the new page. If i use the form action in the popup window page then the new page is open in the same popup window as i...
7
by: Boki | last post by:
Hi All, I can't pass data to another form: in form2: private void button1_Click(object sender, EventArgs e) { Form1 form_copy = new Form1();
11
by: venkatagmail | last post by:
I have problem understanding pass by value and pass by reference and want to how how they are or appear in the memory: I had to get my basics right again. I create an array and try all possible...
12
by: raylopez99 | last post by:
Keywords: scope resolution, passing classes between parent and child forms, parameter constructor method, normal constructor, default constructor, forward reference, sharing classes between forms....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.