473,804 Members | 3,330 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1638
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.strName s = me.textbox1.tex t

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim dataentry As New popupForm

dataentry.Show( )

End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

Me.TextBox1.Tex t = popupForm.strin garray

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(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

stringarray = Me.TextBox1.Tex t.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******** *******@TK2MSFT NGP15.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
1300
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 |----> SystemFrm <---ChildForm dim Data() as CustomClass Public GetData() as CustomClass public SetData(x, data)
6
5916
by: varlagas | last post by:
We disabled the antivirus software but the problem persists. Any clues? Many thanks in advance! Panagiotis Varlagas ======================================================================= 2005-07-28-10.39.02.015001 Instance:DB2 Node:000 PID:1568(db2syscs.exe) TID:2440 Appid:0A00153A.C90B.050728083720
2
6906
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 don't help me out at all. Delphi had a data module that was shared between an applications forms but I don't see any way to do this in C#. Lets say I have two forms, the first with a data grid and the second with field that should contain the...
3
2853
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 referenced and utilized by both the Windows Forms application and the Mobile Device application. Are there any "gotchas" (ie. warnings) that anyone knows about in following this approach? Robert W. Vancouver, BC
2
301
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. My questions regard the data tier, that is, how I should construct the data objects so as to reduce memory usage while optimizing page performance? 1. I'll be using data sets. How can I share a single data set across the multiple web forms? 2....
1
1921
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 1.1 application (Telligent's Community Server) compiled with VS.NET 2003. App B runs in a virtual sub-directory of App A. Both applications run fine. Both site's ASP.NET tabs are set appropriately (A = 2.0.5X B =
3
2448
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) plus some 3rd party controls can see it the datatables etc etc. Is there anyway when i open the second form that this information that has already been loaded into my in-memory dataset be available on all my other forms... and still be strong...
11
2782
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. Once that is opened one (or more) properties forms can be opened. What is the best method for sharing data between the properties forms and the main child form? I need to alert the main child form when a value is modified in a properties form so I...
1
1767
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 can be opened - 1 user at a time. The MDB Options - Advanced - Default open mode = shared Open databases using record locking is checked
9
1990
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 "settings" form and constantly found myself adjusting my "main" form entities to be static and inevitably just passing in the "main" forms 'this' instance to the "settings" constructor to simplify it all.
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10571
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10317
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7615
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.