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


ADVERTISEMENT

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

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 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

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

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

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

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

Storing Data In Classes?

Apr 25, 2012

I have propetie get set classes, and a constructor to quickly set them all.The only concern I have is that the byval in the constructor class and the byval in the set() properties, might be inefficient because the parameter is copied twice? Should I use ByRef? Or is that too dangerous?

'Config data for an Environment.
Public Class Environment
Private msEnvName As String

[code].....

View 6 Replies

.net - System.Data.SqlTypes Classes?

Jan 20, 2012

Since most of the projects I work on are exclusively SQL Server 2005/2008 database driver, I was wondering about the implications of using System.Data.SqlTypes classes as data types in my VB.Net Framework 4.0 code.For example currently I define integer variables as Dim X as Integer.Using System.Data.SqlType classes I would define my intege variables as.Dim X as System.Data.SqlTypes.SqlInt32 implications for performance, serialization and databinding. One difference would be that all variables would default to Null.

View 2 Replies

Working With Data Organized By Classes

May 30, 2009

I am working in vb2008. How to store Class/Structure instance data into a database as single objects.
SomeClass
.name
.address
.age
.etc
Say I have a hundred instances of "SomeClass" stored with data. Is there a way that I can store each of my hundred instances as a hundred objects to a hundred Access database records. I am trying to avoid having to mirror my class structure into a datatable and treat each instance as a single object which can be stored into a single database column name.

View 6 Replies

Use LINQ To Filter Collection Of Nested Classes To Yield Dictionary Of Unique Properties Of Those Classes?

Jan 23, 2012

I have two classes, one nested in the other. [code]Neither "Name" or "ID" are unique between operations and records.I wish to construct a dictionary using LINQ = Dictionary(Of String, Of List(Of Integer), whereby the keys are uniqe examples of Names in my collection and the values are the collective set of distinct IDs that are associated with those names.

View 2 Replies

VS 2010 Structure Classes So That The User Interfaces Though A Single Class While The Supporting Classes Are Hidden From Their View?

Jun 13, 2012

How can I structure my classes so that the user interfaces though a single class while the supporting classes are hidden from their view? I think its best understood in an example:

Public Class MyInterface
Public Economic as EconomicClass
Public Sub New()
MyBase.New()

[code].....

So you might ask why am I even separating them? It's strictly for others who will be working with this interface. I need to funnel them though a logical structure:

interface.Economic.MyMethod
interface.Currency.MyMethod
etc

This way everything is already handled for them in the background and they only need to run the method they need. I don't know if I can have it both ways in VB.NET.

View 23 Replies

Hiding Mainform In Mainformload?

May 7, 2011

[code].....

View 1 Replies

Make My Mainform Invisible?

Mar 10, 2010

I made a birthdaylist. You can store birthdays in it, and it will alert you on the day a person has his birthday. To do that the program has to startup when the computer starts up, and give the alert if neccesary and then close itself again. This all works, but the mainform is visible in that period.

View 5 Replies

Using Hide Method To MainForm?

Jan 15, 2010

I'm trying to go to a different form my main form and while I'm using the selected form I want the MainForm to hide. I've put the code MainForm.Hide() at the top of the code of the JobInformationForm where I'm directing the program. I thought this would cause the MainForm window to hide. However, I'm getting an error saying Declaration is Expected. How do I use this MainForm.Hide() feature?

View 3 Replies

Create A Generic For All The Classes Having Common Data?

Aug 2, 2010

I need to create a generic for all the classes having common data.I am having a Test.xsd dataset.In that dataset I am having 3 Table Adapter.

pgaddressTableAdapter1
pgaddressTableAdapter2
pgaddressTableAdapter3

Code is here. You can see all these classes having same methods. I want to create a generic class for these class.

[Code]...

View 2 Replies

VS 2010 Calling Subs And Functions Within Classes That Are Within Classes?

Oct 24, 2009

Here is some example code of what I mean:

vb
Public Class Form1
Private Sub Button1_Click(ByVal sender as Object, e as systemEventArgs) Handles Button1.Click

[Code]....

View 5 Replies

Pass Data Between Subroutines And Functions Using Public Classes?

Oct 31, 2009

I would like an overview of System.EventArgs. I have an understanding of System.Object where I can pass data between subroutines and functions using Public Classes. I am curious what EventArgs do?

View 3 Replies

Utilize Classes That Inherit The System.Data Name Space?

Mar 9, 2009

I would like to utilize classes that inherit the System.Data name space.Specifically, I would like to have classes CarColumn, CarTable, and CarSet derived from DataColumn, DataTable, and Dataset respectively.I would like to be able to add additional properities to each class. As an example this is how I would like to reference items within the classes:

CarSet.CarTable(0).Columns(0).foo
CarSet.CarTable(0).bar

I know that VB.Net is not capable of Multi-Inheritance.

View 1 Replies

VS 2005 OOP Classes - Can't Clear List Of Data Saved

Dec 3, 2009

bare with me here ok I posted on here a while back, like month to 2 months ago about creating an array of data (user inputed data). But was suggested to go the class route. After weeks of lengthly reading came up with a list collection class.

[Code]...

View 4 Replies

Winforms Data Binding: Custom Classes Or Datatable?

Jul 8, 2009

Am in the process of architecting a new windows forms application, and I intend to use Visual Basic 2008 and SQL Server Express 2005. This is my first application in .Net and I really want to observe the best OOD & OOP principles to create an application that is easy to maintain and extend (add new functionality). My issue is in regard to databinding on the UI. From experience, what do you guys recommend to use for databinding? Should I return datasets/datatables from my Business Layer and bind these to UI controls or should I return Business Objects and bind these to UI controls? And what are the pros and cons of each approach?

View 1 Replies

Application Startup MainForm Is Loaded?

Apr 1, 2010

I have mainFom and a subForm. what I am trying to do is application startup MainForm is Loaded

(2) in the Load event of mainForm. I am creating the SubFom and made it visible and also making MainForm disable

[Code]...

View 4 Replies

Dispose Form Opened In MainForm Tab?

Apr 19, 2010

I have a MainForm which has tab Control and several independent form. I open each Individual From in the tab of the main form. A "Close Tab" button on the MainFrom closes the current tab, its implementation is below.

This closes the current tab but what I also need is to dispose the From whose tab is closed but I am not sure how to get the instance of the form.'[code]...

View 2 Replies

Position A Messagebox In The Center Of MainForm ?

Nov 12, 2009

Is it possible to position a messagebox in the center of your MainForm instead of the center of the computer screen? This is really confusing for beginner computer users, if your mainform will be in the top left corner and the message box in the middle of the screen, it won't be very clear that the messagebox belongs to your application. (well to us it is, but not to old people).

View 3 Replies

Windows Forms: LoginForm And MainForm?

Jun 14, 2010

Currently, I have a LoginForm that authenticates a user and it works fine. I have a MainForm, which is displayed if a valid username and password is entered. I have done this by using the following code in my LoginForm:Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

[Code]...

Now this does exactly what I want except I fear it's a work around and it's not the best approach. Also, note that I am using Me.Hide() to hide the LoginForm, is there a way to show the MainForm and then close the LoginForm instead of hiding it? Doesn't Me.Hide() call creates an overhead?

View 7 Replies







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