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


ADVERTISEMENT

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

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

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

Declare A Static Variable As Global?

Oct 25, 2006

How can i declare a static variable as global in vb.net?(Global static variable)

View 5 Replies

Static Variables On A Web Garden?

Aug 17, 2010

Do vb.net static variables work on an IIS web garden?

View 1 Replies

Difference Between Static And Shared Variables In .NET?

Jun 22, 2009

exact diff b/t Static v/s Shared variables in VB.NET?

View 3 Replies

.net - When Are Inline Static Variables Initialized In A Class

Aug 10, 2010

Suppose we have a class like:

Public Class Question
Private Shared _field as Integer = CrazyIntegersRepository.GetOne()
' Some other useful things go here
End Class

And the method GetOne throws an exception... How can we manage that? Is a good practice to rewrite that into a static constructor? When is the GetOne method going to be executed if we leave it there in the inline _field declaration?

View 3 Replies

Should Threads Update Global Data In The Main Program

Mar 18, 2011

I want to launch a bunch of threads, each performing the same task, and know in main() when each finishs and it if it was successful or failed.The solution offered was to use a ConcurrentQueue, but other posts have recommended using a BackgroundWorker Class, or a thread pool.Is there a definitive answer?Again, all threads perform the same code and have a pass/fail result. I want to run more than there are available threads so as soon as one thread finishes I will launch another asap - I want tehm to stress a remote systems as much as possible (reather than stressing my local PC with too many threads, so I will need to experiment to determine the optimal number of threads).

View 4 Replies

Use Of Static Local Variables In Lazy Loading Property

Sep 19, 2011

I just recently learned about the uses of static local variables in VB.NET and wondered about it's potential use in lazy loading properties.

Consider the following example code.

Public Class Foo
Implements IFoo
End Class

[Code].....

As far as i can see, this has a few advantages over the usual implementation, primary your inability to access the variable outside of the property, as well as not having to use an additional variable.

My question to you is: Which of those is the "right" way to do it? I know that static variables have additional overhead, but is it bad enough to create, in my personal opinion, unclearer code that can be misused easier? How much performance do you lose compared to the "traditional" method? How does it matter for small classes compared to huge factories?

View 2 Replies

Local Variables In Shared Method Work Like Static Variable In C?

Aug 23, 2011

Will the list in this shared method keep its state throughout the life of the method? Or will a new list be created every time this method is called?

[Code]...

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

VB 2008 Why Are Static Variables Set Equal To 0 In The Declaration When 0 Would Be The Default Value Of The Numeric Variable

Apr 21, 2010

Why are static variables set equal to 0 in the declaration when 0 would be the default value of the numeric variable anyway when it's first declared? Not including the "=0" in the static declaration seems to work with no problem.

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

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

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







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