Absolute Beginner

I am sure this is so simple....

I need to create a global variable. When I use the professional edition at college I just type it in underneath the box that says 'Windows Form Designer generated Code', and bobs your uncle! However, Express doesn't have that on the screen and it has brought me to a standstill on chapter 3 of my book.

Can anyone help, because this is how I am feeling after 3 hours of looking

Re: Visual Basic Express Edition Global Variables

Absolute Beginner

I have changed the
Dim number as integer
Public number as integer

And it seems to be working.  If you think I'll have a problem later just let me know.


Re: Visual Basic Express Edition Global Variables

Luca_Dellamore - MS

Yes, we moved the 'Windows Form Designer generated Code' to another file since anyway you are not supposed to edit it (if you really want to see it it is called Form1.Designer.vb and you have to click the Show all files icon in solution Explorer)

You should not have problem: it is exactly the same think than what you did with the Professional edition in college ( keep in mind that your variable is a member variable of your Form Class)
If you want to use a Global Variable that is accessible from all form instances  you could add it to a module

Luca Dellamore

Visual Basic Test Team

Re: Visual Basic Express Edition Global Variables



since the people who wrote the pdf document but decide not to respond to their indicated email address for help I decided to enter this forum.

I cannot find 'Windows Form Designer generated code' in any of my projects - neither under Show all files in the Solution Explorer but the tutorial asks me to edit it.

So what can I do

Any help greatly appreciated.



Re: Visual Basic Express Edition Global Variables


It's a sub node of the form - click the little + next to the Form.vb file and you should see it.

Re: Visual Basic Express Edition Global Variables


It looks like the Professional edition you are using at college is not Visual Studio 2005, but Visual Studio 2003! That version includes the "Windows Form Designer Generated Code" banner when you start a new project.

The IDE has changed between 2003 and 2005. When you start a new project in 2005 Professional, you just get a clean screen with only

Public Class Form1

End Class

on it. It's exactly the same with VB Express. I have all these editions on my computer for comparison (since I teach and need to know what my students will be seeing). There are a lot of other differences between the 2003 and 2005 editions. You can open projects written in 2003 in 2005, but not the other way around. Your tutorial may have been written for the 2003 version. Possibly, your teacher had used the tutorial with the older 2003 version and didn't upgrade the instructions for the latest 2005 version. I would point that out to him/her. Which textbook are you using Is it the latest edition for 2005, or does it say "Visual Basic.NET" which would refer to the older version.

In order to create a form-level variable, you declare it just below the Public Class Form1 line and above the first procedure. You would generally use Private instead of Dim. In order to access the variable in another form, you use Public instead of Private and preface the variable name with the form's name and a dot. In order to create a global variable that doesn't need to be prefaced with the form's name, you open a new module -- select Project/Add Module from the menu. Choose Module from the listing and click Add. The variables in the module need to be declared with Public.

Re: Visual Basic Express Edition Global Variables


Thanks so much Dave and also Solitare for your answers. They were quite helpful.

Actually, I found it in the Form1. Designer.vb.

As Solitaire bascially said: the pdf doesn't match the free VB Express 2005 nor the 2008 beta version and therfore everything looks in some parts quite different.

Kind regards,