473,396 Members | 1,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How To Create/Declare Global Variable/s in VB.Net (Web Forms)

Hi all,
I am a newbie in VB.Net and was kind of lost in programming using it compared to the old VB6.

In VB6 I was able to create, declare or assign values to global variables. But now, it seems that every variable should be included in some class (I'm not sure).

What I need to do is to have some global variables and use them to different web pages without using the classes. What I mean is I do not like to use this sample:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Class FirstForm
  3.     Public StringTest As String
  4.     'then assign some values to StringTest
  5.     StringTest = "abc123"
  6. End Class
  7.  
..then use that StringTest variable in other webforms..

Expand|Select|Wrap|Line Numbers
  1. Dim SecondForm As New FirstForm
  2. Dim SecondString As String
  3.  
  4. SecondString = SecondForm.StringTest
  5.  
.. something like that. Can somebody show me how to do it please? Thanks.
Jul 19 '11 #1
0 1416

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: francisl | last post by:
I have a problem when I declare global variable. If it is string, dict, array or tuple, everything goes fine, but with int, I get an "used before declaration" error. here a sample : vardict =...
3
by: PatrickRThomas | last post by:
his question has probably been asked a million times, but I can't get this to work. I'm trying to create a global variable that contains some HTML so that I can reference it from multiple...
1
by: David DeLella | last post by:
I am writing a piece of software which loads multiple parts into different panels. Each panel can access other panels by accessor methods. My team wants to create a global variable of type Queue...
1
by: Davids | last post by:
I am not having any success, in my master.cs page I assign a variable to be used within all other pages: public partial class MP_master { public string MyString = "this string is global"; } ...
5
by: Deecrypt | last post by:
Hi, I would like to pickup a value from a textbox and make it available to be used by every method within a class. I havent done anything like this since VB 6. Any suggestions? Cheers ...
1
by: Gandham | last post by:
hi i am sujatha how to declare global varibles in .net 2005
16
by: aeo3 | last post by:
I need to define a global variable that many files will see it, this variable is a pointer to class. but i failed to do it. I have a set of classes each in separated files
1
by: lokesh kumar | last post by:
where and how to declare global variable in vb2005 ? EggHeadCafe - .NET Developer Portal of Choice http://www.eggheadcafe.com
2
by: ncsthbell | last post by:
At a form level I believe I can create a variable as" Public v_name as string and this variable would be available to all events on the form. (I think!) I would like to create a 'global'...
4
by: Mister Richards | last post by:
I am trying to create a global variable in C++. I am fairly new to C++ and keep getting an error message my getDoubleNumbr function does not recognize the number variable. I know that the error is...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.