Transferring Data Across Forms - Global Variables?

May 27, 2009

I have 2 forms in this application. One form is just a simple SQL statement that is generated into a grid. It displays columns/rows. From there I want to be able to click on a row and have the first column of that row transferred to another form. In the second form I want it inputted into a text box. So, the user doesn't have to copy the record back out of the form then open the other form and paste.

The form opening and closing is not the problem. The problem is getting the data to transfer from one form to another!! I am not sure how to do it.. I have only been coding in VB for a few days and no formal training. I am aware of global variables and would be willing to assign the data to a variable and then have it transferred into the textbox of a the second form.

I do not know how global variables work in VB. This is what I got so far............
'The user clicked the transfer button.
Dim obj As System.Data.DataRowView = grid.Current
MsgBox(obj.Item(0), vbInformation, "Selected Data")
[Code] .....

View 2 Replies


ADVERTISEMENT

Global Variables For Data Exchange Between Forms

Sep 14, 2011

Is it a good practice using global variables in a VB (.NET) application in order to exchange data between forms? As global variable I mean a public variable defined in a module and not a public member or property of a class. Moreover as my personal rule I never access a global variable from a class, but I pass the values to the class via functions.

[Code]...

View 1 Replies

VS 2010 - Modules VERSUS Forms For Global Variables

Dec 19, 2010

I was a VB6 programmer. And back in the day global variables, functions and subroutines were put in a module. The program started in the module using a sub named Main(). Now in vb2010 it looks like using sub Main() is possible only for console apps, which is not what I want, I'm still trying to write a windows app but it looks like everything has to go at the top of the starting form?? How is this good coding practice? Shouldn't public vars and functions be in their own module?What is considered best practice?Are there any links that would walk me through the differences between vb6 and vb2010?

View 2 Replies

Define Some Global Variables Of A Class - Variables Occupy Memory?

Mar 23, 2012

I define some global variables of a class as follows:

Private Class MyClass
Private var1 as Decimal
Private list1 as List(Of string)[code].....

But I found that after this form is closed, all above variables, var1, list1, list2 still exist in memory. I thought they should be collected by gc since the form is already disposed as I confirmed.

Add: I have monitored half an hour after the form is closed. But these variables are not collected by gc. I have an automatic update procedure on the form which uses above variables.Since the above variables still hold values, the automatic update procedure is always called which causes exception. (One quick fix is to check if form.isDisposed in update procedure. But I do not think this is elegeant. Besides, these variables occupy memory.)

View 2 Replies

Use Variables Or Properties, And Global Or Static Variables In A Class?

Jun 9, 2012

I'm new in .NET programming.I have a class Form1 that includes Button1_Click event.Button1_Click creates a multiple Text Boxies at run time)Here is the class:

Public Class Form1
Dim shiftDown As Integer
Dim counter As Integer

[code].....

View 3 Replies

Variables - Passing Data Between Forms?

Jan 24, 2011

I have a form that has a button, when clicked it pops up a Dialog Form. Within this dialog form the user needs to select some data and when the user is finished they click the OK button. Once they click the OK button it needs to return an integer back to the previous form.I created a Dialog Form and tried calling it via the code below:

Dim intResult as Integer = frmData.ShowDialog()
Debug.Writeline(intResult)

However, it seems I can only return DialogResults (Abort, Cancel, Ignore...)I was wondering how I can try this without having to create a public variable and storing the result there.

View 3 Replies

.net - Creating Global Variables In Asp.net Using C#?

Nov 25, 2009

I was working on window appication previously where i used to create global variables using modules in vb.net, but i found that in C# there is no concept of modules. so how can i create global vaiables in C#

View 9 Replies

.net - Global Variables And DLL Files?

Nov 16, 2009

I want that global variables that sit in some DLL will be seen from other DLLs and EXE of that project.

I included in that VB file "Option Explicit On" as the first line .

But still no one can see my variables that were defined in that file . I made that all DLLs of that project depend to that one with the definition

I am using module and all my variables are public .

Option Explicit On
Module LPSoft_Core
#Region "Public"

[Code].....

View 1 Replies

Declaring Global Variables In Vb?

Sep 29, 2011

The user clicks a button, a new form is generated where the user enters his/her password? How can I keep an in-memory copy of the username?

For instance in web forms, I can just use Session ("User"). How can I replicate this with winforms?

View 3 Replies

Global Variables And Functions

Mar 24, 2010

how can i create global variables and functions within a visual basic project?

View 6 Replies

How To Declare Global Variables

Aug 16, 2010

How I can declare global variables in vb.net that I can access them in all windows of my application?

View 5 Replies

How To Handle Global Variables

Feb 2, 2009

I'm creating an App that requires a few global variables (user information mostly) and I wanted to know the best why to declare these. I would like to create a "global" class with properties for each variable, but the property values reset with every instance of the class. Plus, what is the must excepted way to declare globals, I've heard placing them in their own module is as Globals is not a good practice.

View 7 Replies

Save All Global Variables?

Aug 20, 2009

I've got a RPG style game I am putting together - mostly to teach myself vb.net. I am using alot of global variables to hold game values.[code]...

My question is -- I am trying to make a "SAVE" and "LOAD" the game's state. Is there a simple way to save the values of all my global variables, without having to type everysingle variable out. Is there anyway to call upon all my global variables at one time, and possible save/load them to a text file ?

View 3 Replies

Using And Accessing Global Variables?

Apr 13, 2011

I want my "textbox.text" variable of my main form to be accessible by my other forms. Can somebody please guide me on making that a global variable?

View 12 Replies

VS 2008 - Global Variables?

Apr 4, 2009

I have this little code here in vb 2008, I created a flag var to see if the user has clicked the button "enter" so the flag would be set to true. If its true then the game would begin...

I have a label that says "Press enter to Play", and if the user presses play the flag is true, the label visible is set to false. I have the keydown event to check if the enter button has been pressed, i checked if it works and it does, but the var of the flag is always false in my other subs...

Thats the thing with vb i dont understand is when you make a public variable, and when you change the value of the var in a sub, it doesnt change globally.

CODE:

View 15 Replies

C# - Application Variables Global To Webgarden?

Jan 12, 2010

I am currently trying to program an online drawing program using the HTML5 canvas.the thing is, I need to have the current canvas saved somewhere globally. Static variables work, but they do not get shared across a Webgarden. This results in two different drawings being created.I will have to somehow create a new application object which is shared. I figured I will need an external application holding them.

1) How do I replace the application object with my own?
So either I will have to make my own program and call to it with remoting or use the ASP.NET session state server for application variables. I favor the Session State Server though.

2) How do I use the session state server for my own variables? How do I access it?

I searched high and low on the internet and only found the ideas mentioned above, but no help executing them.

I mainly code in VB.NET, but I can also understand C# code for examples.

A little info on my application:The client side has two canvas objects on top of each other. The top canvas object us used for drawing stuff, the canvas object below it holds the drawing in the end.When something is drawn, it is sent to the server in it's base64 representation. (getDataUri).The server puts this graphic on top of a stored Bitmap object through a Graphics object.

How the changes are being distributed to the other clients, I am working on that right now. Either I transfer the complete picture or each and every change that is submitted. This should work through Server Push. If this does not work thoroughly I will have to save and timestamp changes. A link to the current implementation, which is not currently fetching changes (but they get transfered to the server... With the problem that some reach one instance some reach the other on either w3wp in the webgarden) from the server is here: http:[url].....

View 1 Replies

Calculator - Declaring Global Variables?

May 11, 2009

I need to write a simpe calc. program to add, mutiply, subtract and divide. I want to have two textboxes that I enter numbers in and when I click a button, +,-,/ or * a third text box will display the result.Rather than declaring my variables inside each instance of a click event I would like to declare them globally so I just need to perfom the calculation on them and display result. However declaring them globally doesn't work for me. I;ve tried the variables inside the btnAdd click event which works, but as I said I'd prefer to declare them onece globally.

Public Class Form1
Dim number1 As Double = CDbl(txtNum1.Text)
Dim number2 As Double = CDbl(txtNum2.Text)[code]...

View 1 Replies

Declare Global Value Type Variables With New?

Dec 29, 2009

What happens if I do: Dim x As New Int32? Is a object of int placed on the heap? If it is, maybe your application would be able to access global variables faster if they were reference types.

A global variable as an value type should be somewhere at the bottom of the stack most of the time and it might take more time to get to this then to get a object from the heap. Unless it's the same story with the pointer of this object is also at the bottom of the stack of course.

View 9 Replies

Displaying Images With Global Variables

Oct 29, 2009

I need to send up to to selected images (such as an apple) to pictureboxe's on a results page. at the moment I'm using global variables to attempt to display the images like this:
Me.pbItem1.Image = New Bitmap("images\" & gstItem1 & ".jpg")
Me.pbItem2.Image = New Bitmap("images\" & gstItem2 & ".jpg")
I get a directorynotfoundexception 'Could not find a part of the path '\images\apple.jpg' error. I'm new to VB and think this must have something to do with the default path or something.

View 4 Replies

Making Variables In A Procedure Global?

Mar 15, 2012

I know the title seems pretty trivial but i have an issue and i can't seem to get round it, i have the following code within one sub procedure..

Dim X, Y As Integer
X = 32
Y = 285

[code]....

View 2 Replies

Tool To Identifying Global Variables?

Mar 30, 2011

Is there an automated tool for VB.Net that will identify all global variables in a project?Short of that, is there any scripts that can be used that will facilitate a manual review of global variables?There seems to be tools for C/C++, but not for VB.Net:Tools to find global/static variables in C codebases there a tool to list global variables used and output by a C function?

EDIT:
My current approach uses the following VS REGEX searches:
For finding global variables:

[code].....

View 2 Replies

Declare Some Global Variables For Use In Various Subs/functions?

Oct 21, 2011

At the head of a module, I wish to declare some global variables for use in various subs/functions.

What is the difference between.Dim x as string and Private x as string / Public x as string, and when would I use one over the other?

View 1 Replies

Sub Main In A Project-static And Global Variables

May 17, 2009

I try to create a sub main in a project but i can not.I have create a module called Module 1 and inside i have created a Main Sub which is intended to creta a thesaurus_form class instance , like this Code: Module module 1Public Sub Main()Dim thesaurus_form2= New Thesaurus_formEnd SubEnd module.Instead of this, once it has cretaed a first instance of the thesaurus_form class, it creates another one what i dont want at all..How can i do do make it execute the code which is inside the thesaurus_form_load sub..I also can not create a global variable or a staitc variable, because i receive this message.static is not valid in a member variable declaration.

View 2 Replies

VS 2005 Global Functions And Variables Within Solution?

Jun 23, 2009

I have a solution with 5 visual basic projects in it. Each project has an identical module with a few functions and constants - like handling our RS232 data, outputting events to log files, etc, etc..

If I want to change any of this common code, then I have to manually go through and change in each project. Is there a way to have a single module or class that's shared throughout the projects in the entire solution? I've considered creating and referencing a class library, but I'm likely to be making several little tweaks and changes to this "global code" and that method sounds like it could be just as awkward. Can I not just have a module that's visible to all projects, and compiled into each one seperately when the solution is built?

View 3 Replies

VS 2008 Store Global Variables, In My.Settings Or My.Namespace?

Dec 4, 2009

Which is the best way to store global variables, in My.Settings or My.Namespace. The reason I ask is because I need to know certain boolean values if certain forms are open from other forms. At present I am defining Global Boolean variables in My.Application, which give the result I require.

View 3 Replies

Setting Global Variables Within Web Project On Login And Set Expiry Time

Dec 1, 2011

I'm developing a revised version of a system I have been using for years, but with all the advantages of .NET features that were not around when I first made this. It's proving a steep learning curve! So, when a user logs in through my Login.aspx page which simply compares username/password to Database record, the system creates a session variable containing the user's Username and various other things. There are two type of variable which will be common to all elements of this system
User Specific data, Username, Permissions, etc

Setting variables, drawn from a database of pre-set facilities which are setup within the system, some will determine which facilities work, how they work, and some will be dependent upon the User's permission. Obviously, I could set everything within the Session data, but that'd be inefficient wouldn't it? If I were to set these globally available variables in my App_Code, how would I go about setting this up so that, for example, those variables which require a database call, are set for the duration of the Logged-In session and do not require constant Database lookups? Further to that, those variables which are dependent on the session state, would need clearing on each LogOut. I am using VB.NET.

View 1 Replies

Forms :: Transferring A Textbox Value To An EventHandler Process?

Dec 9, 2011

I am using Visual Studio express 2008 to load a form, perform a task at a given interval. My problem is:

1) I am able to populate a textbox with the desired text (a pathname);

2) I can get the timer event to work perfectly;

3) The problem arises when the timer conditions are met and I need to perform a task based on the value of the text box.

4) The value from the textbox becomes lost and when i hold my mouse cursor over the textbox:

[Code]....

On a side note, the script runs perfectly when i hard code in the pathname, but this doesnt suit the work i would like this script to do.

View 8 Replies

Transferring Totals From Three Forms To A Final Form?

May 3, 2009

I'm taking my first (and only) beginning programing class for Visual Basics 2008. I'm working on my final project and have hit a snag. A little background info - I have been able to code everything except for two final steps (but they are my most difficult steps), on these final steps I've gotten two suggestions on other sites, one person helped me with the coding which I used for my form1, but it I still have several errors, and another person suggested that I use a module.

Here is the issue. I have totals on three forms that need to pass through to a final form, and once they are on the final form they need to show up in an itemized list and need to then be totaled again. I actually have a total of 5 forms including my first form aptly named form1, which incidentally is where someone told me I should set up my whole 'connecting the totals' form, and I believe the guy was on the right path with helping me but, I'm still obviously pretty lost on this last segment of coding. Since I had little difficulty with the majority of my project, I didn't think this last bit would be so difficult. I'm going to list my coding for each form below. My project is due Tue morning May 5th Eastern Standard Time, just in case someone starts reading this on or after that date. Just in case it helps explain the issue, I will also post my listing of error codes from my VB project, and they all are centered around my form1 (which is the form that I'm trying to set up the transfer through of the form totals). I also see that I can post attachments so in case it will help I'm going to post my project in the attachment too.

Error Codes:
Error1Event 'Load' cannot be found.
Error2Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

[Code].....

View 1 Replies

Transferring Data Between Pages?

Jan 7, 2010

I have the following code in place: Protected Sub btnBuy_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuy.Click Session("ShoppingList").add(New OrderInfo(txtQuantity.Text)) Server.Transfer("ShoppingCart.aspx") End Sub

View 5 Replies

Transferring Data Between Two SQL Servers Using VB?

Jun 12, 2011

The title of this thread perhaps does not explain my problem correctly.Actually i am developing a financial software for a company.The software is similar to a banking system. The software is being developed using VB 2008 and SQL Server 2008.The company has its branches located at different locations. They are having a centralized SQL Server at their Head Office.The branches are connected to Head Office using a VPN.Now what we are worried about is when the VPN gets disconnected.For that we will be having a SQL server installed at each of the branches.When VPN is connected the the details entered will be directly at the Head Office database,Meanwhile a program will be executed which will get details from the Head Office database at each of the branches in a XML file.When a branch gets disconnected from the VPN another program will get the XML details into the Sql Server installed at the branch. When the branch is connected again Another application will create a xml file from the local server and insert its details into the HO server.The sizes of the XML are reaching upto around 150 to 200 mb. I am using Dataset.WriteXML and Dataset.ReadXMl. I have tested this on my local machine it is taking upto 30-40 secs.I dont know how much it will take when the actual application is installed. How can i speed things up ? Does anyone have any idea on how i can do the whole process more smoothly and faster?

View 5 Replies







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