Click here to Skip to main content
15,926,281 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionADVAPI32.lib Pin
vbvic12-Jul-06 20:38
vbvic12-Jul-06 20:38 
AnswerRe: ADVAPI32.lib Pin
Dave Kreskowiak13-Jul-06 2:38
mveDave Kreskowiak13-Jul-06 2:38 
QuestionHow to dynamically create a query in Access database using Vb.net/C# and ADO.Net Pin
Hari Prasad Karnam12-Jul-06 20:33
Hari Prasad Karnam12-Jul-06 20:33 
AnswerRe: How to dynamically create a query in Access database using Vb.net/C# and ADO.Net Pin
George B Gilbert13-Jul-06 15:57
George B Gilbert13-Jul-06 15:57 
Questionhow to upload the webform ?? Pin
areon2512-Jul-06 17:49
areon2512-Jul-06 17:49 
AnswerRe: how to upload the webform ?? Pin
Christian Graus13-Jul-06 4:28
protectorChristian Graus13-Jul-06 4:28 
QuestionPopulate a form Pin
str5012-Jul-06 15:20
str5012-Jul-06 15:20 
AnswerRe: Populate a form Pin
Richard Blythe12-Jul-06 18:06
Richard Blythe12-Jul-06 18:06 
I don't do alot of database interaction but I think I can help you with the interaction between the two forms. You will need to create a Public object reference from Form2 to Form1. Below is a short VB.NET sample that copies the text from a TextBox1 in Form1 to a TextBox2 in Form2. This sample will assume that you have already created two forms named: Form1 and Form2.

In Form2, insert the following code right below the initial class/inherits declaration:

Public Class Form2
Inherits System.Windows.Forms.Form

'Insert this code
Public myObject as Object

Now save the changes to Form2.
One thing you may or may not know is that when Objects are passed to one another, the receiving object does not get a copy of the the passing object, it gets the memory reference to it! That is great news for us. We will now create code to pass Form1's object reference to Form2.

Go to Form1 and it's code view. I will assume that you are showing Form2 by clicking a button of some sort, therefore I will use the sample name Button1.

Private Sub Button1_Click(..) Handles Button1.Click

'sample form2 declaration
Dim pForm2 as new Form2

' here's where the object reference is passed!
' Me is the command for the current form
pForm2.myObject = Me
pForm2.Show
End Sub

The two forms are now linked based on the object reference. Now to illustrate this, create a textbox in each of the forms. (TextBox1 in Form1 and TextBox2 in Form2) Also, add a button to: FORM2.
Form2 will be sending the text from TextBox2 to TextBox1. In Form2's designer mode double click on the newly created Button1 to open the code view and .net will automatically create the click handler sub. In that click handler, insert the following code:

Private Sub Button1_Click(..) Handles Button1.Click
'Note: This button1 code should be in form2 not form1!

'this the code. "Ctype" is casting an unknown object
'to a known object aka. Form1
CType(myObject, Form1).Textbox1.Text = Textbox2.Text
End Sub

There you go! Now run the program and test the code. Form2's textbox should send text to Form1's textbox. You should be able to go from there. Good Luck!

Richard Blythe
QuestionRe: Populate a form Pin
str5013-Jul-06 0:35
str5013-Jul-06 0:35 
AnswerRe: Populate a form Pin
Richard Blythe13-Jul-06 5:44
Richard Blythe13-Jul-06 5:44 
GeneralRe: Populate a form Pin
str5016-Jul-06 6:11
str5016-Jul-06 6:11 
AnswerRe: Populate a form Pin
George B Gilbert13-Jul-06 16:31
George B Gilbert13-Jul-06 16:31 
GeneralRe: Populate a form Pin
str5016-Jul-06 6:15
str5016-Jul-06 6:15 
GeneralRe: Populate a form Pin
George B Gilbert16-Jul-06 11:56
George B Gilbert16-Jul-06 11:56 
GeneralRe: Populate a form Pin
str5016-Jul-06 14:43
str5016-Jul-06 14:43 
GeneralRe: Populate a form Pin
George B Gilbert16-Jul-06 15:35
George B Gilbert16-Jul-06 15:35 
GeneralRe: Populate a form Pin
str5016-Jul-06 16:11
str5016-Jul-06 16:11 
QuestionUpdating table using SelectCommand.CommandText? Pin
Rashar12-Jul-06 10:48
Rashar12-Jul-06 10:48 
AnswerRe: Updating table using SelectCommand.CommandText? Pin
kumarprabhakar7412-Jul-06 19:39
kumarprabhakar7412-Jul-06 19:39 
QuestionScreen scrape Pin
swissmiss8612-Jul-06 10:13
swissmiss8612-Jul-06 10:13 
AnswerRe: Screen scrape [modified] Pin
mr_1234512-Jul-06 12:35
mr_1234512-Jul-06 12:35 
QuestionHelp with string comparisons in SQL Pin
kscadi12-Jul-06 9:36
kscadi12-Jul-06 9:36 
QuestionAdding a working scrollbar to a panel Pin
Joshua Boyle12-Jul-06 8:07
Joshua Boyle12-Jul-06 8:07 
AnswerRe: Adding a working scrollbar to a panel Pin
Dave Kreskowiak12-Jul-06 8:14
mveDave Kreskowiak12-Jul-06 8:14 
GeneralRe: Adding a working scrollbar to a panel Pin
Joshua Boyle12-Jul-06 8:20
Joshua Boyle12-Jul-06 8:20 

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.