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


ADVERTISEMENT

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

Sharing A Timer/Variable Between Windows?

Mar 6, 2012

I have a timer running like a scoreboard countdown timer. Is there a way that I can display that same timer into two windows forms (winforms) without resorting to properties?

View 1 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 Parent Variable With Child Objects?

Nov 5, 2010

I am developing a new class which is a control that inherits from the "Panel" class. In this new class, I have three objects that are generated every time I create a new instance of the class. For simplicity, I will call this class "garage" and the three objects "BMW," "Lexus," and "Acura." So each new garage has three types of cars.

how can I share a variable from the Parent class with all of it's child objects? i.e. The garage has an array variable called "tires" which all three cars use. Rather than create each car object with the tires parameter, I would just like to keep the tires parameter in the parent class so that all my child objects can use it. I know that normally the parent class should provide the child class with all information when creating the child but it would seem redundant to pass the entire tires array each time since all three cars use the same tires and the tires object never change.

View 4 Replies

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

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

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

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

VS 2008 Sharing Variables - Private Sub Could Use The Variable Created On Private Sub

Jul 23, 2010

if for example i have two private sub I declared a local variable on private sub a... is there a way that private sub b could use the variable created on private sub a? Im asking because im in a problem in my app were using global variable is not an option to make the long story short

View 5 Replies

Pass A Variable To Another Form Or Else Make The Variable Visible To Both Forms?

Sep 5, 2010

Using Visual Basic 2008 Express. I need to pass a variable to another form. Or else make the variable visible to both forms.

View 4 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 :: Can Make Variable Actually Seen As A Variable?

Feb 17, 2011

I have a VBA form in Microstation I am using to try and help automate a task. The only problem I am having is I am reading a textbox (Filebox.Text) and setting it as the variable (FN). It works, because I used Msg.Box (FN) to test it. However, in two of the lines of code, I am trying to use (FN) to pass the typed in filename to the command to run in Microstation. Unfortunently, it gets passed on as (FN).dgn instead of the actual filenale typed into the textbox. Is there a way I can make the variable actually seen as a variable? Code on Pastebin: url....Also, not sure if this is the right section, 100% new to VBA, coming from a world Bashed together.

View 3 Replies

Forms :: Wonky Variable Passing In Forms

Apr 22, 2010

This is my first Windows app to create since VB6. I've been in the world of ASP and ASP.NET for many years. However, now I have been asked to create a simple app that needs to be windows based.

[Code]...

View 4 Replies

How To Use A Variable Between Forms

Oct 23, 2009

I have two windows forms in my application, and I want to have variables that work between them. How would I do this?

View 2 Replies

Use The Same Variable On Different Forms?

Oct 28, 2009

I want to calculate the score on one form and display the score on another form

View 7 Replies

CanNot Pass Variable Between Forms?

Sep 11, 2009

i have a dialogbox (dialog1) i will assign the input from textbox a variable to the from1 but i cant do that.the variable in form1 is Dim get_from_dbox As Long i try to assign to it from dialog1 like below it fails form1.get_from_dbox = Textbox1.Text but i can assign to textbox??like that which works well

form1.RichTextBox1.Text=Textbox1.Text I am new programing i know i am wrong .don't know where?

View 1 Replies

Forms :: Display Variable In Msg Box?

Sep 20, 2010

I am struggling to find out how to use a msg box to display the value of a variable.

I've tried a number of permutations, and searched for hours to find a tip.

My code is currently:

Private Sub btnShowTotalCost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShowTotalCost.Click
If (radCorpTravel.Checked) Then

[Code].....

View 10 Replies

Passing Variable Between 2 Forms?

Jun 15, 2010

i have 2 forms -> form 1 and form 2

in form 1 -> 1 button
in form 2 -> 1 textbox and 1 button

when I click button in form 1, it will show the form 2..how can i pass the variable (data from textbox in form 2) into a variable in form 1 after clicking the button in form 2 ?

View 8 Replies







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