473,383 Members | 1,880 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.

sharing data between forms

As mentioned earlier I've been away from coding for about 5 years. Know I
know why :(
I've been trying to work out a critical detail, hard to do on Thanksgiving
;)
Push a button on form1, form2 appears, I enter some text push a button and
get the data back to form1.
In the "old days" we had globals to pass stuff like this through. (as a C
programmer by background
I always found that pretty poor). But now I can't find a mechanism to do
what I want. I've done a lot of MSN and google searching but nothing that
works.
(have to admit, I really need to change my Fileopen and other classic basic
code to .net)
Thanks to all, and hope you had a great day of turkey.


Nov 25 '05 #1
3 1623
whenever i want to share info between forms, usually i create a module. i
dunno if its the rite way to do it, being only a n00b programmer at the age
of 16, but i create a new module and create a variable in the body which you
can store info in, for example

''code in module

Public strNames as String

''make it public so all forms can access it

''in your code of your form

private sub btnclick_click(...)handles...

module1.strNames = me.textbox1.text

end sub

then you can just read in the variable and write to it

hope this helps
--
-iwdu15
Nov 25 '05 #2
Al,

There are probably thousand of possibilities.

However the first question you have to ask yourself is it
a dialogform
a normal (existing beside the other form)
a mdi (existing inside the main form)

If it is a dialogform than it is very simple and basicly

\\\
dim frm as new myform
frm.PublicValue = Mywhatever
frm.Showdialog
myWhatever = frm.PublicValue
frm.dispose
///

I hope this helps,

Cor
Nov 25 '05 #3
I will try to help, start by designing your main form. In the Solutions
window, right click on the solution name and click on Add, then Add Windows
Form, and name it popupForm, then add your text box and 2 buttons. Get the
physical stuff out of the way. If you start by just letting the new form be
called default 'form2.vb' then thats fine too

In the button click event to make a new form2, you would create an instance
of the form with a Dim, you get there by double clicking on the button you
created, and inside the routine type the handler, then also for button 2 add
the other handler

keeping in mind Form2 is popupForm

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

Dim dataentry As New popupForm

dataentry.Show()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click

Me.TextBox1.Text = popupForm.stringarray

End Sub

Yes, technically you could create a sub to handle your new popup forms
creation and whatever, this is for example use

In the form2 or popupForm, create a textbox and a button, double click the
button

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click

stringarray = Me.TextBox1.Text.ToString

End Sub

Now, do you want the text in your main form1 to change whenever text in the
other form changes? Thats far more complicated and should be part of a new
upgrade to VB release 3?

Anyhow, to update the first textbox the only way I know of is to use a thing
called an Observer Pattern. The changing data in the textbox triggers an
update event and the form1 textbox has to be subscribed by giving its
address to the event.

If anyone knows another way? Im interested to hear it

"Al_C" <ac****@bicnet.net> wrote in message
news:%2***************@TK2MSFTNGP15.phx.gbl...
As mentioned earlier I've been away from coding for about 5 years. Know I
know why :(
I've been trying to work out a critical detail, hard to do on Thanksgiving
;)
Push a button on form1, form2 appears, I enter some text push a button and
get the data back to form1.
In the "old days" we had globals to pass stuff like this through. (as a C
programmer by background
I always found that pretty poor). But now I can't find a mechanism to do
what I want. I've done a lot of MSN and google searching but nothing that
works.
(have to admit, I really need to change my Fileopen and other classic basic code to .net)
Thanks to all, and hope you had a great day of turkey.



Nov 26 '05 #4

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

Similar topics

0
by: Paul Schouten | last post by:
I was wondering if anyone could help me with this... I am having problems sharing data between child forms. the setup is as follows: mainFrm <--- MDIForm |----> ViewFrm <----ChildForm |---->...
6
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= ...
2
by: Red Green | last post by:
I am trying to switch to C# from Delphi and I am having some trouble finding some information. What I need to do should be simple but I have been through a dozen books and done web searches that...
3
by: Robert W. | last post by:
I'm embarking on a project that will have both a desktop application and a Pocket PC application. It seems logical to have as much code as possible sitting in a shared project, which would be...
2
by: Mervin Williams | last post by:
I am using Infragistics UltraWebTab (a tab folder control for ASP.NET). My tab folder control will include five tab pages with a separate web form on each, and these web forms will share data. ...
1
by: Tod Birdsall, MCSD for .NET | last post by:
Hi All, I have two ASP.NET applications which I am trying to have share forms authentication. But I am running into problems. App A is an ASP.NET 2.0 Beta 2 application. App B is an ASP.NET...
3
by: Chris Thunell | last post by:
I have 2 forms, on 1 form i use the wizards to create a strong typed dataset with tables from an SQL database... and from that i can do stuff like: me.daEmployee.fill(me.dataset11.tblEmployee) ...
11
by: Nick | last post by:
Hello, Please pardon my ignorance as this is something I should know, but I'm a little unclear. I have an MDI based app. It is setup so the user opens a file and the main child form is created....
1
by: Bob Alston | last post by:
Having problems sharing an Access database on a Windows 2000 PC. The other PC is windows 98 (as I recall) but NOT windows 2000! The 2nd PC has a shortcut to the MDB on the primary PC. The MDB...
9
by: kirk | last post by:
I have program.cs, my "main" form and then a "settings" form. My "main" form existed for awhile and I had constants, instantiations, properties, etc within it created. I went to create my...
1
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: 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...
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
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.