Sharing Data Between Forms?

Nov 17, 2009

I am working with several RFID readers that perform different function in my vb.net program. Currently each reader port number is hard coded into the respective form. For example, reader 3 operates on COM1. However, this will be problematic when installing on different machines.

What I would like to do is have a "configuration" form where the user can select each reader and then select the COM port. Then all other code references these settings. What would be the best approach for this.

The only way I know to do it currently is to place this information in a small database and then have the forms reference that database, but it is a lot to do for such a seemingly trivial task.

View 3 Replies


ADVERTISEMENT

Forms :: Sharing Data By Declaring Object

Mar 31, 2010

I have two forms A and B. B is a child of A - i.e. I have a button on A that pops up form B. I want B to be able to access and change data (e.g. an instance of an object etc.) in A and also to call some function in A. At the same time I'd like to preserve the right to alter the data in A without opening B. I've achieved this using the following (i.e. by declaring the object and method as Friend):

Public Class frmA
Friend _data as Hashtable
Friend Sub GetData()
If _data IsNot Nothing Then
_data As New Hashtable

Is there anything inherently wrong with the what I've done and if so how can I achieve a similar result? (It seems to work - I can read, add to and change the values in the _data Hashtable from within form B and when B is closed the values persist i.e. I can access the changed values from within form A. I just dont know if its a horrible fudge).

View 2 Replies

Save Data When Sharing Databindings Across Forms?

Sep 24, 2010

I am sharing databinding when opening a detail form a summary form. The data is shared fine. What I don't know is how to save any data that may have changed, or to create a new record.[code]...

View 2 Replies

Multiple Full-Screen Forms Sharing Data?

Sep 13, 2011

My question is in two parts:

1) I am writing an application for a touchscreen which will have several different Forms - each of which will be full-screen. What is the best way to achieve this? Hide/show each Form as the user navigates between screens? MDI Parent with multiple Child Forms becoming visible 'on top'? Or is there a more elegant solution?

2) I would also like a 'banner' on the top of each Form (or always visible on the top of the MDI Parent, etc) similar to a 'navigation frame' on a website. This banner will display a clock with the current time, and the current GPS location (meaning that a Timer will be used to get/set these values every 1000 milliseconds). I thought of using a UserControl for the banner - but if this is used on multiple Forms then I will end-up with multiple Timers all waiting 1000 milliseconds to update essentially the same information.

Is there a best practice for this type of scenario? - my thoughts so far are using the "Main" Form for Global Timers, etc - but then how do I update all Form clocks each second? (without iterating through all visible Forms... which seems messy).

View 5 Replies

Sharing Business Logic Between Windows Forms And Web Forms?

Feb 4, 2010

My question is, am I able to share a business logic layer seemlessly between the two presentation layers or is there anything I need to watch out for. I'd really like to not have any duplication of business logic, so any advice would be more than welcome.

View 3 Replies

Forms :: Sharing Settings XML Document Between Forms?

Dec 26, 2009

I have an application built that has several forms. I use an XML file to store settings data (mainly folder names for data output) and I need each form to be able to access and modify the data. I'd also like each form to access functions from a main form (such as file parsing functions). I have read articles about properties and inheritance but I need some guidance as this topic is pretty confusing.

[Code]...

View 10 Replies

Sharing Resources Between Forms?

Apr 12, 2010

I have some icons and images that are stored as embedded resources in my form1.resx file. Is there any way I can access these resources from my Form2 without adding the icons as project resources?

View 5 Replies

Sharing Text Between Forms?

Sep 9, 2008

How do I share text between forms?I want a box to popup exactly like a input box, but needs to be multiline, Is there any east way to do this or will I have to create a second form?If so, how do I share the string between forms to then output in a textbox on 1st form?

Also, I have VB 2008 Standard, and I want to build an application for a handheld, Is it possible to build an application and then pass it over to someone who has the professional version to make it work on pocket pc? Or does the entire build have to be on pro already?It's a very simple program...

View 4 Replies

Sharing UI Validation Between Forms?

Jan 25, 2012

I am trying to figure out how to seperate my business logic from my forms. This is my first attempt at doing this, but I would like to figure out how to handle events from multiple forms within a class. I have found myself routinely writing the same logic over and over in each form class and its time I figure out how to completly seperate out that logic in winforms so I can reuse the methods across all of my forms.

So basically I have this click event in form1:
Private Sub btnSubmit_Click(sender As System.Object, e As System.EventArgs) Handles btnSubmit.Click

[code].....

View 1 Replies

Sharing Variable Value Between Forms

Jul 31, 2009

When I declare a variable as public, shouldn't it be available in another form? I am trying to write a windows mobile prg with 12 static mileage points, form1 has the 12 buttons for start point, but when I call form2 with the destination points, my start variable value is not carried over. I intend to then assign a mileage based on the two points and write to file on mobile device. We support 12 schools, and I want my employees to track mileage easily.

Public Class main
Public start As String = "start"
Public dest As String = "dest"
Public miles As Decimal = 0
[Code] .....

View 4 Replies

Sharing Variables Between Forms?

Jun 16, 2010

i've almost completed my Yahtzee game except for the high scores function. I've got everything worked out except how to take the highscore variable from Form1, and share the data with Form 2

View 12 Replies

Best Practice For Sharing Variables Across Forms?

Mar 27, 2011

I need to share variables across two forms in vb.net. One of them is the main form and the other is a child form.

Create a static/shared variable in one of the forms and access it in the other forms via:
Form1 frm = new Form1(); //creating object of parent to access shared variable
frm.a = "abc"; // passing value

Send an instance of the main form to the child form when creating the child form. The variables can then be accessed via a property function. Create global variables in a module. This seems like the easiest option, but I doubt it is the best option.I also read something about delegates and events, but I don't know how to implement this.

View 4 Replies

DB/Reporting :: Forms Sharing 1 Dataset?

Sep 21, 2008

What I mean is that when I make queries on a Parent Form. Child forms can also retrieves the datatable /datarows from its parent form.

View 3 Replies

.net - Sharing Mdb Access Connection Among Multiple Forms?

Sep 7, 2010

I'm starting to put in a database into my application, however I'm drawing a blank on how to share a database connection among the dozen or so different forms in my MDI application. I'm assuming this has to do with interfaces or something but I can't find any relevant examples anywhere. Can someone help me out? Ideally what I'd like is when the app is loaded up there is a call to a function in the forms loading area which establishes a single connection to the mdb, that I can then call via any form so I don't always have to open/close connections everytime I need to update the db?

Here's a basic example of the mdb database access code I've got working:

Dim dt As DataTable = New DataTable()
Dim OleDbTran As OleDbTransaction = Nothing
Using connJET As OleDbConnection = New OleDbConnection("connection string here...")

[code]....

View 1 Replies

Child Forms Are Sharing Controls And Conflicting

Feb 7, 2012

I have a form that can spawn a child form, something like:[code]I want to be able to launch multiple children. Unfortunately, I seem to be getting conflicts within the controls of the children. One button will run the other child's control, etc. They also seem to think that their class-level variables are accessible to each other. Private Shared variables like the following are conflicting (one form thinks it's seeing the other form's "mp3file" variable as their own):[code]How do I spawn children forms that keep their controls and data separate?

View 1 Replies

Sharing Multi-dimensional Arrays Across Different Forms In VB?

Jul 9, 2011

I have a very simple 2D array, it holds a list of song titles, their genre, and their runtime. frmMain loads the array from a text file and allows me to manipulate it and boil it down to a desired (implicitly sized) playlist. i want to THEN pass that playlist array to a second form, frmPlaylist The problem i'm running into....When frmPLaylist calls the Property from frmMain I receive an error that VB cannot convert the string value to a two dimensional array. Simplified...frmPlaylist is all locked and ready to receive a 2D array, but frmMain seems to only be sending a single string variable. on frmMain

Public ReadOnly Property PlaylistOut() As String
Get
Return mstrTimedPlaylist(,)

[code].....

View 1 Replies

Master Detail Form+bindingsource Sharing The Same Dataset On 2 Different Forms 1 With Grid Other With Editing

Dec 9, 2009

Am new to VB, can anyone tell me very simple how to share the MAIN Bindingsource with an detail form where i want to edit 1 record from the main datasource?
andreg

View 3 Replies

Sharing Data Between Class And Form?

Sep 30, 2010

I am in a VB programming class and I am having an issue with a program that I created. The focus of the program is creating a class to do calculations and sharing the data with a form.

The problem that I am having is with a certain piece of data that is shared between the class and form. To be more specific, it is two check boxes that each have their own variable as boolean, done as a true/false if checked/unchecked situation.

When I step through the program, somehow the values get changed entering the class for calculations. For example if it was true, false, it comes out as false, true when the class accesses the data. There are other variables and data types that get pulled but these are the only ones that are being altered.

View 3 Replies

Sharing Data Between Classes And Mainform?

Apr 13, 2011

I have done programs in the past with VB6 using the winsock control to receive data to be processed. I would like to do the same thing in vb.net but I am having problems. I have done numerous searches and consulted numerous books and articles, but haven't found the best approach for accomplishing the following.

I would like from 1 to 20 clients to be able to send a string to the server to be processed. It would be nice to if the clients could connect to same port and use async processes to open/accept more connections. One of the books (Visual Basic 2008 Recipes) has a recipe for creating "Multithreaded TCP Server that supports Asynchronous Communications".

I am trying to base my program off of that example and modify it for my application. The problem I am having is how to share data with the Main form and the classes that handle the communications. The TCP class has two classes contained in it. One class for listening for connection, beginning the accept client and the other class (clienthandler) for completing the connection and getting the data. I would to be able to get the data from the clienthandler class and post on the main form. I have trying to have a public property for the data but I think my confusion comes in because the clienthandler would be created new for every new client. The mainform would not know how many of the new clienthandlers were created etc.how get the data to the main form and clear the data when done. I have even considered putting data into MSMQ and having main form pull data out.

View 7 Replies

Sharing Data Between Multiple Threads?

Jul 7, 2011

I know a little about threading and delegates, as well as socket programming. I'm working with a VB.NET-compatible SDK called TrueVision3D to create a small online game for me and my friends. The problem is that I cannot for the life of me figure out how to pass data from one thread to another. I've created 2 seperate threads on seperate forms.

The first thread is created on a form titled FrmLogin, and it contains all the socket code. I need to be able to update variables in the second thread, which mainly consists of a render loop. The second thread is created on a form titled FrmMain. I'm not quite sure if it matters what forms the threads are created on, I'm just trying to give as much information about the issue as I can. I've tried using delegates and events to pass information from the thread back to the form it was created on, which works fine, but how do I pass data to the second thread from the first?

View 1 Replies

Transfer Information / Sharing / Data?

Sep 5, 2011

where i need to start to create "Online" (or transfer data / sharing data /Transfer information ) program?

I mean that two or more different computers with the program can connect with each other ... Like Chat, Online games, etc..

View 2 Replies

Sharing Data Between Server And Moving Laptop

Sep 2, 2010

I have a PC with sql server 2005 express, my application works with it great, is it possible to install another copy of my application to a laptop that will move around and wont have access to the data all the time. trying to find something like SQLCE has(RDA)so it can see the data make changes and when it returns it submits all the changes. Is this possible and how can it be done.

View 6 Replies

Multithreading, Events And Cross Thread Data Sharing?

Dec 1, 2011

I am building a code library to be used by a 3rd party developer. Neither my code or the 3rd party have any UI controls involved. It's purpose is a combination of providing the ability to look up information from a database while at the same time polling it and throwing events when a set of conditions are met. Naturally the only way it's going to be responsive to the 3rd party library's commands is via multithreading since everything in a single thread stops once you start polling the database.

The sub I am using is part of an object that I create in the main thread and attempt to have it run via a thread, when a condition is met I have it update a property in that object, throw the event (or execute a callback in my latest attempt) and then attempt to have a simulator for the 3rd party control read the property.It's easy to setup the multithreading part, the hard part appears to be throwing the event so it is seen in the original thread and the data is available there. Any attempt to do this generates a cross thread error when the data is read.

I attempted to use delegates and calling methods asynchronously and using the callback function but still get cross threading errors.Is my only possiblity to use a background worker, using either the progress changed or runworker completed events? Even then am I going to be able to set the property in the function from one thread and read it in another?

View 1 Replies

Sharing Data Between Multiple Projects In Single Application?

Jun 11, 2011

I have a windows forms application with one exe and several dlls(Class libraries) in a single solution. The application uses common data that is used across all the dlls. I would like to load the data when the application is starting up and use the loaded data at various points in the dlls so that I do not have to load the common data again and again. How can I share the data loaded in main EXE across the DLLs?

View 2 Replies

VB Program - Activex EXE Data Sharing (the Time Is A Bit Anxious)

Nov 12, 2009

I am in the main process using Activex EXE to create a sub-process, Activex EXE project inside a class module, class module which there are two instances of the event the equivalent of two threads, I defined the standard module module1.bas as public variable a, in two instances running at the same time, how the definition of public variables are not used, such as a private variable, each carrying out their respective variables of the same name! For example the implementation of a = a +1 statement, let the first instance of a run, a steady increase from 1; when executed when an instance of 2, a should be an instance of a value when the two began to increase, but also from two examples of 1,2 , ... began to increase.

[Code]...

View 1 Replies

Adding A Close Button To BindingNavigator And "sharing" It With Other Forms

Nov 19, 2007

I want to add a close button to a custom navigator. That's fine.

Now what if I want to use it on every form that I would create ? What is the best way (Is subclassing possible for this control in that case, ...) ? Any inspiring code somewhere even for another type of control ?

View 9 Replies

2 Forms Sharing The Same Value (Dim Name As String="App1")

Sep 11, 2009

I want 2 forms the main form which is form1.vb and the second form which is form2.vb to share the same value:

Dim Name As String="App1" so i can use it by simple doing that:
[Form1.vb]
Public Class Form1

[Code].....

Or it could be better if i didnt have to add a reference to the main form the string Name should be already declared in the second form so i could use just:

Textbox1.Text = Name

View 6 Replies

Forms :: Share Data Between Forms (as Opposed To Passing Data)

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

Passing Data Between Forms Without Any Public Methods Or Properties On The Forms

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

Create A Data Forms With Forms Wizard In VB 2005?

Jan 21, 2010

How to create a data forms with the data forms wizard in VB 2005

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved