Declare Store And Access "global" Variables?
Jan 17, 2011I have an application that I'm writing and I'm trying to declare two variables from my sql server, store the values and pass them to my forms.[code]...
View 5 RepliesI have an application that I'm writing and I'm trying to declare two variables from my sql server, store the values and pass them to my forms.[code]...
View 5 RepliesHow I can declare global variables in vb.net that I can access them in all windows of my application?
View 5 RepliesWhat 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.
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?
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 RepliesI need regarding declarations of global variable.. I created a module here is the script.
[Code]...
and then I set the value of that variable in my Login form and then my PROBLEM is when accessing it on the my Main form and I want to display the data of that variable in a textbox, the variable does'nt hold the value that I already set. I'm waiting for replies!
i could use Global x as string in vb6 in a module to declare it with global privelages, how can i do this in vb2008? how to declare a global variable in vb2008? so that i could use it anywhere i want. i know global variables are not recommended in programming but i need one.
View 4 RepliesI 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.)
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].....
how to declare out global variable? i tried out but get error.. below is my orginal code
[Code]....
How can i declare a static variable as global in vb.net?(Global static variable)
View 5 RepliesHow do I declare a global variable in VB - these variable need to be accessible from all the vb forms. I know how to declare public variable for a specific form. but how do I do this for all the forms in my project.
View 4 RepliesI'm trying to declare a array that I want to use in the module and in the forms. I like it to be usable all over but I cant get it to work.[code]...
View 3 RepliesI would like to declare a list above Sub procedure and to be able to add/modify it. I would like to have something like this:
[Code]....
When i run the above example i get an error like: Object reference not set to an instance of an object.
Just working on getting more fluent in Visual Basic over the summer so I'm still sharp for my next visual basic class. My teacher went over variables, but only in local scope.I have looked everywhere, but I can't find exactly what I need. I'm making an alarm clock of sorts, and I have this code to populate the minute array and the hour array.
Public Class Form1
Public Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[code].....
I'm wondering whether it is possible to declare a global variable in a click event. I need to declare an array of a specific size. The specific size is generated using a series of IF statements. I only need to know how to declare it.
View 1 RepliesI 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 RepliesI 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].....
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?
how can i create global variables and functions within a visual basic project?
View 6 RepliesI'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 RepliesI'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 ?
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 RepliesI 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:
trying to figure out how to declare items here. here is the
[Code]...
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].....
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]...
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.
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]....
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].....