Click here to Skip to main content
15,918,007 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralMobile Application Pin
Usharva28-Feb-08 23:35
Usharva28-Feb-08 23:35 
GeneralRe: Mobile Application Pin
Dave Kreskowiak29-Feb-08 3:44
mveDave Kreskowiak29-Feb-08 3:44 
GeneralabControl Problem Pin
soniasan28-Feb-08 23:30
soniasan28-Feb-08 23:30 
GeneralRe: abControl Problem [modified] Pin
yogesh_kumar_agarwal28-Feb-08 23:34
yogesh_kumar_agarwal28-Feb-08 23:34 
Questionhow can i use values form one form to another in vb.net Pin
r_mohd28-Feb-08 22:24
r_mohd28-Feb-08 22:24 
AnswerRe: how can i use values form one form to another in vb.net Pin
yogesh_kumar_agarwal28-Feb-08 22:58
yogesh_kumar_agarwal28-Feb-08 22:58 
AnswerRe: how can i use values form one form to another in vb.net Pin
darkelv29-Feb-08 3:38
darkelv29-Feb-08 3:38 
AnswerRe: how can i use values form one form to another in vb.net Pin
tjskcp5-Mar-08 18:07
tjskcp5-Mar-08 18:07 
Try this example:
No need to change any control properties in this example. Coding follows after the explanation.

Create a new solution with 2 forms, Form1.vb and Form2.vb.
Create a text box and a button on Form1.
Create a text box on Form2.
On the code view for Form1.vb, create code for a public share textbox. In the load function, assign the public share to TextBox1. Create code for Button1 click event to open Form2.vb.
On the code view for Form2.vb, create code in the ChangeText event of TextBox1 to access the shared textbox control from Form1.vb.
Compile and DeBug.
Click on Button1 to open Form2
Type text into TextBox1 on Form2 and it will automatically show in TextBox1 on Form1. No other variables to hold data are necessary. After closing Form2, data can be processed on Form1 as needed.

Below is the code (name your variables appropriately):

***Form1.vb************************************

Public Shared tb1 As TextBox

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
tb1 = TextBox1
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim newForm = New Form2()
newForm.show()
End Sub

***Form2.vb*************************************

Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Form1.tb1.Text = TextBox1.Text
End Sub
************************************************
************************************************

To use this method, the shared controls need to be in the first form opened (not necessarily the first form in your program) and accessed by the second form. The shared controls need to be initiated and assigned values before the they can be used by another form.

This method can be used for any type of control you want accessed by another form.

I use this type of setup in most of my programs. Easier than keeping track of too many public variables, especially in programs with a lot of forms that require user input. You will need to experiment to see how to use this in your forms.
GeneralLighttpd & HTTPWEBREQUEST question Pin
Daniel Lopez28-Feb-08 17:35
Daniel Lopez28-Feb-08 17:35 
Questionmenu strip Pin
Tauseef A28-Feb-08 17:23
Tauseef A28-Feb-08 17:23 
GeneralRe: menu strip Pin
Xmen Real 28-Feb-08 17:38
professional Xmen Real 28-Feb-08 17:38 
Generalerror-cannot check the checkbox in datagrid after 2nd search Pin
Eunice (VB junior)28-Feb-08 14:51
Eunice (VB junior)28-Feb-08 14:51 
QuestionSave image in PostgresSQL DB Pin
nishkarsh_k28-Feb-08 8:56
nishkarsh_k28-Feb-08 8:56 
GeneralRe: Save image in PostgresSQL DB Pin
Christian Graus28-Feb-08 9:32
protectorChristian Graus28-Feb-08 9:32 
GeneralRe: Save image in PostgresSQL DB Pin
nishkarsh_k28-Feb-08 18:08
nishkarsh_k28-Feb-08 18:08 
GeneralRe: Save image in PostgresSQL DB Pin
Christian Graus28-Feb-08 18:29
protectorChristian Graus28-Feb-08 18:29 
QuestionNeed Help... Dial, Connect and Use a BBS in VB.Net Pin
Scyrious28-Feb-08 5:03
Scyrious28-Feb-08 5:03 
GeneralRe: Need Help... Dial, Connect and Use a BBS in VB.Net Pin
Christian Graus28-Feb-08 9:38
protectorChristian Graus28-Feb-08 9:38 
GeneralRe: Need Help... Dial, Connect and Use a BBS in VB.Net Pin
Scyrious29-Feb-08 3:12
Scyrious29-Feb-08 3:12 
QuestionAdd records to databound datagridview Pin
David Mujica28-Feb-08 4:40
David Mujica28-Feb-08 4:40 
GeneralRe: Add records to databound datagridview Pin
Dave Kreskowiak29-Feb-08 3:21
mveDave Kreskowiak29-Feb-08 3:21 
AnswerWorking now Pin
David Mujica29-Feb-08 9:39
David Mujica29-Feb-08 9:39 
QuestionAcessing certificate store of local system Pin
shinlang28-Feb-08 3:51
shinlang28-Feb-08 3:51 
GeneralRe: Acessing certificate store of local system Pin
Dave Kreskowiak29-Feb-08 3:27
mveDave Kreskowiak29-Feb-08 3:27 
GeneralCan't find appropriate control Pin
cstrader23228-Feb-08 3:32
cstrader23228-Feb-08 3:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.