Forms :: Passing Values Between Forms
Jul 23, 2009
My scenerio is a form with a button, when clicked opens a form dialog. The dialog allows the user to enter a text box. I want to read the value of the text box from the main form into a variable to be used with an SQL statement. The following code is used to create a new instance of the form dialog if one does not exist:-
[Code]...
View 2 Replies
ADVERTISEMENT
May 1, 2011
Im trying to pass a value of a date control from form1 to form2.on form 1.aspx.vb:
Public ReadOnly Property Property1() As Date
Get
Return StartDate.SelectedDate[code].....
Tried to assign the property to a string, it did not work either.
View 2 Replies
May 27, 2009
I think I'm getting hung up on syntax here. I've got 2 forms and am trying to pass a textbox value from the 1st form to the 2nd. The textbox value is an unique ID #, so it's an integer value in the database. The ID displays in the textbox just fine on the 1st form. When I try to access the value of this ID textbox in code in the 2nd form, I see that the value is empty, or equal to "". But I see a valid ID # on the 1st form. Here's the code that shows me that the textbox equals "".
[Code]...
View 2 Replies
Jun 4, 2012
solid rundown of how this process works using custom events &EventArgs, Im really having trouble wrapping my head around it
View 14 Replies
May 1, 2012
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.
View 2 Replies
Sep 8, 2011
I have a very simple windows forms setup. Form1 has a progress bar and a button on it, when clicked the button opens Form2 which also has a button on it that launches Form3. On Form3 is a button which I want to use to raise an event back to Form1.To achieve this can I add an event handler on form1 that will listen for an event of the type raised in form3? Or do I have to pass references to form1 to form2 and then from form2 to form3?
View 1 Replies
Sep 30, 2011
I have to ask a stupid question:How to pass values from my form into the controls of other form?I made textbox and button in my form1 and Label into the form2 When I click the button, I want to pass the values of the my textbox in the form1 into the labels of my form2
I am a student and totally new to vb.net
View 3 Replies
Aug 5, 2009
To start things up, I have a DLL called clsEmployeeModule, containing forms frmEmpInfo and frmAddEmpName. frmEmpInfo contains a textbox that when clicked displays the frmAddEmpName. Now the latter contains three textboxes (firstname, middlename and lastname) and a Save button. Once the user clicks Save, the values from the three textboxes will be concatenated and displayed as a full name back in the frmEmpInfo form.Below is the code snippet calling the frmAddEmpName:
vb
Private Sub empname_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles empname.Click If genInfo_edit = True Then call_addempname.Text = "Edit Employee Name" End If call_addempname.Show() End Sub
And here's the code snippet from the frmAddEmpName:
vb
Imports clsEmployeeModule Public Class frmAddEmpName Dim callempinfo As New clsEmployeeModule.frmEmpInfo Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click mnFname = firstname.Text
[code]....
When I debugged the program, it showed that employee_fullname was successfully populated with the concatenated values -- however, that wasn't the case for the empname textbox.
View 5 Replies
Feb 6, 2012
I need a nudge in the right direction. I have a user control that has the main form and it calls a secondary form to gather some additional information in some cases. I need to pass the information back from the secondary form to the primary user control form so I can validate the data and save. In the secondary form, I have the following code:
Dim myFrm as new frmOperationComments
myFrm.OperationComments = [comments from form]
myFrm.OperationDate=[Date from form]
I have tried creating two public properties on the user control and setting them, I have created two properties in the user control form called OperationComments and OperationDate. I can set both of them, but when I close or hide the form and go back to the main user control form, the values for these properties or variables are not set. How do you set the values on the main form from a calling form within a user control?
View 2 Replies
Jun 10, 2011
I have two forms and I am running a sql query to provide a set of variables in my first form that I need to pass to my second form. Here is the code that I have:[code]to form 2 which then shows the data retrieved from a sql query in the load event to a datagrid view.
View 19 Replies
Dec 28, 2009
Passing data between forms without any public methods or properties on the forms. everything but the "Controller" class, which I would like you furnish. I just changed the title from "Intermediate" to "Beginner" This solution is an example of the Observer Pattern. The "Controller" class is the "observed" class, which in this case means it publishes events.
' File Definitions.vb
Public Delegate Sub MessageDelegate(ByVal sender As Object, ByVal e As MessageEventArgs)
Public Class MessageEventArgs : Inherits EventArgs
Public Message As String
[CODE]...
The program should initially display Form1, and Form2. Clicking of the button on either form will modify the Title Text of both forms. I think that you will find the final end result to be pretty neat, as it works with any number of open forms not just two. I think asking for the Controller class is easier than asking for the code in the forms. My solution for Controller class has 7 lines of content, 9 lines if you include Class, EndClass. A minimal solution could achieved with only 4 lines of content, but it would a textbook example of bad programming.
View 12 Replies
Jul 28, 2010
I use the code
Dim Selvk As New Selvkost2
Selvk.PassedText = TextBox29.Text
Selvk.Show()
[code]....
in my second form and the text passes. but I need to pass values from 20 textboxes. do I have to copy the code in my second form 20 times an declare passedtext2 and so on or is there an easier way to do this?
View 3 Replies
Apr 22, 2010
This is my first Windows app to create since VB6. I've been in the world of ASP and ASP.NET for many years. However, now I have been asked to create a simple app that needs to be windows based.
[Code]...
View 4 Replies
Dec 17, 2010
Example Form1 with data bound controls and a Public Variable Form1Var.Form2 with data bound controls and a Public Variable Form2Var DataTables are related Form2 Data is related to Form1 Data in a one-to-many.What I am trying to accomplish.When editing Form1 data there is a button to open Form2 if new data needs to be added. on closing Form2 I would like Form1 to remain at the state it was in before opening Form2. If I Change Visibility of Form1 when Form2 is opened upon Retun to Form1 Data is reloaded, if I minimise Form1 when Form2 is opened upon return to Form1 Public variables are reset to defaults.I have many Forms with many controls and buttons to do Lookups or additional add to related tables.
View 2 Replies
Nov 12, 2009
I have a gridview on a form pulling user data. I have also created a basic login system where users login and their username/password is checked against a table in SQL Server 2005.The gridview is on Form 2 but i am having great difficulty in returning the records in the gridview for the user that is currently logged in.
View 3 Replies
Aug 21, 2011
I'm getting a little fustrated, ive been trying to figure out how to allow my main from access to a sub form. what I'm initially aiming for is control of text and font color via a dialog on the main form and the results to appear on the second form, if that makes sense. Most of my knowlege resides around using VB.net for creating games and not progams. ill post the code so you guys might be able to get a better understanding of what im looking for as a result.
[Code]...
View 2 Replies
Nov 27, 2009
I seem to be running into an issue. This may seem like a noob question (which it really is, I only have experience in vb6 from years ago) but what Im trying to do is pass a variable from one form to another. Ive tried telling the first form to set the value of the variable on the second form like so frmsecond.variable = "value" but that does not work. Ive tried placing a public variable in a module to do it, but again, no luck. The only way seem to be able to get it to work is the second form setting the variable by reading the value from the first form like so [code]The problem I have with that code is what if for some reason the selected line gets changed as the form is loading or something to that nature. It doesnt seem very secure.
View 5 Replies
Feb 9, 2009
In VB.net how do you retrieve an value from a object in a different form.
eg:
' on frmMain
MsgBox ("Say ""Hello World"" Mr. " & frmOther.txtName.text)
View 7 Replies
Nov 26, 2011
Quite a few threads on passing data from one form to another, but I'm struggling to work out how to share data between the two - back and forth.
For example:
Class1 is a class with 10 string properties
Form1 has 10 labels ("Label1", "Label2" etc) and a [Configure] button.
Form2 has 10 textboxes and a [Apply] button.
I want to load with Form1, and create an instance of Class1. Click the Configure button and load Form2, passing Class1. On Form2 I want to manually fill in the 10 textboxes and hit Apply. The Apply should update the Class1 instance and close the form.
Form1's Label controls should then be updated with the data from the Class1 instance.
I'm fine creating the forms and classes, as well as passing the class into Form2 with a custom Sub New(EmptyClass as Class1) constructor. This gets the empty class into Form2, but how can I get the populated class back to Form1?
As Form1 already exists I don't want to create a new instance with another custom Sub New(PopulatedClass as Class1)
It's also key to be able to use the Form2 multiple times, basically ending up with a Data class being displayed as part of Form1 but updated using Form2? (For example if the Class has already been created and populated with data when it's passed back to Form2 for the second time I would pre-load the Textboxes with the values already in the class).
View 3 Replies
Apr 10, 2009
I am trying to do a really simple function (atleast it was simple in 6.0)... what I want to do is have two forms. One with a textbox, and one with a button and a textbox (we'll call this one form2). When I add a value to form2 and click the button I want the text to appear in form1's textbox.
My code in form2 is...
' on event button1_click...
form1.textbox1.text = me.textbox1.text
("me" being form2)
Anyways, how to pass a value from one form to another.
View 3 Replies
May 10, 2010
I have 2 forms. Using Visual Basic.On Form 1 there is a populated combo box. This was done so by running a query through it and populating it with PUZ_ID values from a data set.On form two there is a tool strip and below is a search query.I need to be able to select the value i want in the combo box on form 1, and launch a button that opens form 2, which has loaded the data that i binded onto the form.Anyone have any ideas/code or need me to clear this up a bit more?So i need to run something through a query, or make something public or what?
View 2 Replies
May 10, 2010
I have 2 forms. Using Visual Studio.
On Form 1 there is a populated combo box. This was done so by running a query through it and populating it with PUZ_ID values from a data set.
On form two there is a tool strip and below is a search query.
I need to be able to select the value i want in the combo box on form 1, and launch a button that opens form 2, which has loaded the data that i binded onto the form.
So i need to run something through a query, or make something public or what?
View 2 Replies
May 20, 2011
I have two forms named are form1 and form2 (form1.h / form2.h)There are a textbox and a button on form1 and form2.When I clicked the button on form1, it must fill the textbox on form2 and when I clicked the button on form2, it must fill the textbox on form1 how can I do it,when I define #include "Form2.h" in form1.h AND #include "Form1.h" in form2.h, it gets me an error "error C2065: undeclared identifier.
View 3 Replies
Aug 11, 2010
I'm translating a document management application from vb6. I want to program with good habits and technique, so I'm asking for your opinion really rather than just a solution.I have a decent understanding of OOP, but I'm not very experienced in VB at all. What I'm doing now is trying to figure out the best way to pass objects between forms.For example, in my initialization form, I have an object that stores a group of database connections. I need to pass this object around because reconnecting takes a significant amount of time. There are other objects such as user info and permissions.
Public Class Form 1
Dim DB = New DBobject
Public Sub Form1_Load
[code]......
View 5 Replies
Jul 2, 2010
I designed a form simply holding a combo box, button & Datagrid, working well when executed from another erp application.Now i would like to get parameters from the application and pass on to the form. The parameter has to replace the value of Combobox value.
View 3 Replies
Jan 28, 2010
I have a "Open File" menu on form1 that reads the user input data from the selected file, stores them into variables, passes on the var. to my form2 and loads up my form2 with the user input data. My code works But when I close my form2 and button click form1 to open form2, I still see the same input data I want all my text boxes to be blank.
View 8 Replies
Jun 15, 2010
i have 2 forms -> form 1 and form 2
in form 1 -> 1 button
in form 2 -> 1 textbox and 1 button
when I click button in form 1, it will show the form 2..how can i pass the variable (data from textbox in form 2) into a variable in form 1 after clicking the button in form 2 ?
View 8 Replies
May 17, 2012
I have a Form1, the user types a "Client ID" in a textbox if it's not a valid one, it opens a Form2 in which the user selects the correct "Client ID", once selected he presses an OK button. And there comes the porblem.. it opens a new Form1 with the Client ID that he selected from Form2, but I still have the first Form1 opened.
I have two Form1 opened...
I which to keep the original Form1, but with the value sent from Form2..
I'm using this code:
Code in Form1
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
[Code].....
View 2 Replies
Apr 12, 2011
I am working on a program, and I would like to have the program pass a name from on form to another.
This is my code :
form 1 :
Public Class Form1
[code].....
View 8 Replies
Apr 22, 2009
I'm making a simple game as my first personal Visual Basic program, and I've run into a small problem. I'm trying to make it so when you reach or pass certain amounts of experience, you receive 5 stat points, but the best I've been able to do so far is have the program add the points when you are in a small window of 2 values. This is what I have now:
If Val(lblTtlExp.Text) >= 100 And Val(lblTtlExp.Text) < 110 Then
lblStats.Text = Val(lblStats.Text) + 5
ElseIf Val(lblTtlExp.Text) >= 200 And Val(lblTtlExp.Text) < 210 Then
[Code].....
View 1 Replies