473,383 Members | 1,846 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,383 software developers and data experts.

Passing variable between 2 forms

2
I have problem .
Ihave 2 forms , iwant to enter variables on form1 and show them in form2
This what i have soo far
form1
=====
Private Sub Button1_Click(val blala)
Fnamesender = TextBox2.Text
Me.Hide()
Form2.Show()

End Sub

form2
=====
Private Sub Form2_Load(ByVal blabla bla)

Label.text = Fnamesender
end sub

i have a mudule
===========
Module one
Public Fnamesender As String

end module


The Problem is when i enter a text in TextBox2 in form1 and view it in Label its ok , but if you go back to form1 and enter a name in textBox2 it doesnt change in label . how can i clear label
Aug 14 '07 #1
10 2782
hariharanmca
1,977 1GB
I have problem .
Ihave 2 forms , iwant to enter variables on form1 and show them in form2
This what i have soo far
form1
=====
Private Sub Button1_Click(val blala)
Fnamesender = TextBox2.Text
Me.Hide()
Form2.Show()

End Sub

form2
=====
Private Sub Form2_Load(ByVal blabla bla)

Label.text = Fnamesender
end sub

i have a mudule
===========
Module one
Public Fnamesender As String

end module


The Problem is when i enter a text in TextBox2 in form1 and view it in Label its ok , but if you go back to form1 and enter a name in textBox2 it doesnt change in label . how can i clear label

you never explain what is your problem and you can also use like this


Form1
==========
[CODE = vb]
Private Sub Button1_Click(val blala)
Form2.Label.text = TextBox2.Text
Me.Hide()
Form2.Show()

End Sub[/code]
Aug 14 '07 #2
babaze
2
Form1
==========
[CODE = vb]
Private Sub Button1_Click(val blala)
Form2.Label.text = TextBox2.Text
Me.Hide()
Form2.Show()

End Sub[/code]

I still have the same problem even after using your code
Here is my problem
I have two forms form1 and form2
I want to pass variable TextBox2.Text to Label.text in form2 after doing this
i want to go back to form1 and ready to do the proccess again

Problem
Say i entered MIKE in TextBox2.Text in Form2.Label.text i get MIKE , thats good. but if i go back to form1 and enter JOHN in TextBox2.Text
i still get MIKE in Form2.Label.text , Is there a way to clear Form2.Label.text
before reciving the next variable i have tried all , Form2.Label.text="", and clear()
i still cant get it to work . Thanks for your time
Aug 14 '07 #3
hariharanmca
1,977 1GB
Form1
==========
[CODE = vb]
Private Sub Button1_Click(val blala)
Form2.Label.text = TextBox2.Text
Me.Hide()
Form2.Show()

End Sub[/code]

I still have the same problem even after using your code
Here is my problem
I have two forms form1 and form2
I want to pass variable TextBox2.Text to Label.text in form2 after doing this
i want to go back to form1 and ready to do the proccess again

Problem
Say i entered MIKE in TextBox2.Text in Form2.Label.text i get MIKE , thats good. but if i go back to form1 and enter JOHN in TextBox2.Text
i still get MIKE in Form2.Label.text , Is there a way to clear Form2.Label.text
before reciving the next variable i have tried all , Form2.Label.text="", and clear()
i still cant get it to work . Thanks for your time

did you click the command button?
Aug 16 '07 #4
hariharanmca
1,977 1GB
did you click the command button?

Just throw what is the error that you are getting?
Aug 16 '07 #5
Killer42
8,435 Expert 8TB
The textbox won't get updated by magic. If you put a value in it in the Form_Load event procedure, then this will only happen once when the form is loaded. If you want the value to change later, you have to change it.

It's worth noting that hiding a form does not unload it. So unless you explicitly unload Form2 somewhere along the line, using Show on it will not run Form_Load again. It just makes it visible.
Aug 16 '07 #6
pureenhanoi
175 100+
I have problem .
Ihave 2 forms , iwant to enter variables on form1 and show them in form2
This what i have soo far
form1
=====
Private Sub Button1_Click(val blala)
Fnamesender = TextBox2.Text
Me.Hide()
Form2.Show()

End Sub

form2
=====
Private Sub Form2_Load(ByVal blabla bla)

Label.text = Fnamesender
end sub

i have a mudule
===========
Module one
Public Fnamesender As String

end module


The Problem is when i enter a text in TextBox2 in form1 and view it in Label its ok , but if you go back to form1 and enter a name in textBox2 it doesnt change in label . how can i clear label
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim frm2 As Form2
  3.   FNameSender = Text2.Text 
  4.   Me.Hide
  5.   Load frm2
  6.   frm2.Show
  7. End Sub
  8.  
or
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2. Dim frm2 As Form2
  3.   FNameSender  = Text2.Text
  4.   Set frm2 = New Form2
  5.   Me.Hide
  6.   frm2.Show
  7. End Sub
  8.  
Aug 16 '07 #7
Killer42
8,435 Expert 8TB
I don't know about ASP, but in VB6, the Load Form2 will have no effect if Form2 is already loaded.
Aug 16 '07 #8
pureenhanoi
175 100+
I don't know about ASP, but in VB6, the Load Form2 will have no effect if Form2 is already loaded.
My code was Quoted by ASP tag, That dont mean my code was written by ASP (i like the color of ASP-tag only).
If you take a look again, you can see that i didnt call "Load Form2". My code was "Load frm2". Here, "frm2" is an entitiy of class Form2. (i must say sorry about the first declare. It must be: Dim frm2 As New Form2)
Aug 17 '07 #9
Killer42
8,435 Expert 8TB
My code was Quoted by ASP tag, That dont mean my code was written by ASP (i like the color of ASP-tag only).
It certainly makes the keywords stand out.

If you take a look again, you can see that i didnt call "Load Form2". My code was "Load frm2". Here, "frm2" is an entitiy of class Form2. (i must say sorry about the first declare. It must be: Dim frm2 As New Form2)
Good point.

However, this seems like a lot of unnecessary complexity just to show a value on the form when something is clicked. Surely the code should just set the appropriate control on Form2.
Aug 17 '07 #10
pureenhanoi
175 100+
It certainly makes the keywords stand out.

Good point.

However, this seems like a lot of unnecessary complexity just to show a value on the form when something is clicked. Surely the code should just set the appropriate control on Form2.
I dont think it bring up complexity in my code. If you approach programing from Object Oriented, you will see thats the common thing. (if you've ever seen some code was written by elder version of VB (4.0 or lest than) , you can see much code like me. Because, in elder version of Vb, programer cannot call Form2.Show directly. Form2 is a class. Cannot calll <ClassName>.<MethodName>.
Aug 17 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: rickcheney | last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I had a form where the user entered a value into a text box and when a command button on the form was clicked a Report was...
9
by: Max | last post by:
I'm new with Javascript and can't seem to figure out what I'm doing wrong here as I'm not able to pass a simple variable to a function. In the head of doc I have: <script...
2
by: Matthew Clement | last post by:
I'm currently building a form (called frmReports) to set the criteria for a query, but I'm having some trouble with syntax and hope that one of the guru's here can help me achieve what I'm do. ...
3
by: SV | last post by:
Dear all, In my application I have a lot of hidden fields. I want to make them invisible for the users though for debugging reasons I want to make them visible. So I want to add these objects to...
1
by: sofakingfree | last post by:
I keep getting an invalid property assignment error when tring to reference a subform. All I am trying to do is substitute this: Forms!!.SetFocus for this: FormAndSubForm.SetFocus
11
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
13
by: Deano | last post by:
Apparently you can only do this with one value i.e Call MyAssetLocationZoom(Me!txtLocation, "Amend data") This runs; Public Sub MyAssetLocationZoom(ctl As Control, formName As String) On...
1
by: rfr | last post by:
I have a need to use a single version of a Visitor Response Feedback Form on numerous HTML documents. Rather than have numerous versions of this, one on each HTML document, it makes more sense to...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.