Click here to Skip to main content
15,918,976 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionVariable Declaration Clarifications (Newbie) Pin
frankiebaby223-Jul-07 22:40
frankiebaby223-Jul-07 22:40 
AnswerRe: Variable Declaration Clarifications (Newbie) Pin
Christian Graus23-Jul-07 23:25
protectorChristian Graus23-Jul-07 23:25 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
Colin Angus Mackay23-Jul-07 23:39
Colin Angus Mackay23-Jul-07 23:39 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
Christian Graus23-Jul-07 23:42
protectorChristian Graus23-Jul-07 23:42 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
Colin Angus Mackay24-Jul-07 0:38
Colin Angus Mackay24-Jul-07 0:38 
JokeRe: Variable Declaration Clarifications (Newbie) Pin
Luc Pattyn24-Jul-07 2:22
sitebuilderLuc Pattyn24-Jul-07 2:22 
GeneralRe: Variable Declaration Clarifications (Newbie) Pin
frankiebaby224-Jul-07 0:19
frankiebaby224-Jul-07 0:19 
AnswerRe: Variable Declaration Clarifications (Newbie) Pin
Dave Kreskowiak24-Jul-07 4:16
mveDave Kreskowiak24-Jul-07 4:16 
frankiebaby2 wrote:
Dim:- Can be used to declare variables within the entire Form if placed before all the Private Sub crap, other wise known as the General Declarations area. Otherwise is for Local Variables only.


Dim declares variables and specifies their types and a possible initialization values.


frankiebaby2 wrote:
Static:- When used with a Local variable, the value is preserved for the lifetime of the application (while the program is running).


Declares a variable as "persistant" between calls. For example, if you have a sub that is called many times and a variable in it is declared static, it retains it's value between calls. The variable is not destroyed and recreated to an intialized value. This can only be used at the procedure level.


frankiebaby2 wrote:
Public:- Must be contained in a standard Module not a Form and are visible throughout the entire project. (A Module is a Form without a user interface.)


Specifies that a variable is visible outside the scope it is declared in. Public can only be specified at the namespace, module, or file level. Specifying Dim is optional.


frankiebaby2 wrote:
Protected:- (Your answer goes here )


Protected variables or procedures are only visible to the class they are declared in or in derived classes.


frankiebaby2 wrote:
Friend:- Access is similar to Public, only Friend is restricted to only code within it’s project (application).


Friend means that the element is only visible to code inside the same assembly (.DLL, .EXE) as the Friend element.


frankiebaby2 wrote:
Shared:- (Your answer goes here )


Only a single instance of the Shared element exists and it exists without an instance of the class it's declared in.


frankiebaby2 wrote:
Protected Friend:- (Your answer goes here )


A combination of the two above.

frankiebaby2 wrote:
Private:- Appears to be the same as Dim. Is it? (Your answer goes here )


Declares the element is not visible outside the scope it is declared in. For instance, Private members of a class are only visible inside the class and any code in it. It is NOT a replacement for Dim.


The complete variable declaration line looks like this:
    [ <attributelist> ] [ accessmodifier ] [[ Shared ] [ Shadows ] | [ Static ]] [ ReadOnly ] 
Dim [ WithEvents ] variablelist

You do not have to have an attributelist.

You do not have to specify an access modifer, Public, Private, Protected, Friend, Protected Friend. If not access modifier is specified, Private is assumed.

Everything I just wrote, came from here[^].


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Variable Declaration Clarifications (Newbie) Pin
frankiebaby226-Jul-07 23:32
frankiebaby226-Jul-07 23:32 
Questionmaking a game using visual basic Pin
not insane yet!23-Jul-07 22:32
not insane yet!23-Jul-07 22:32 
AnswerRe: making a game using visual basic Pin
Christian Graus23-Jul-07 23:21
protectorChristian Graus23-Jul-07 23:21 
AnswerRe: making a game using visual basic Pin
Colin Angus Mackay23-Jul-07 23:22
Colin Angus Mackay23-Jul-07 23:22 
AnswerDo your own homework Pin
leckey24-Jul-07 3:02
leckey24-Jul-07 3:02 
Questiondisable a listbox item... Pin
shaz jazz23-Jul-07 22:13
shaz jazz23-Jul-07 22:13 
AnswerRe: disable a listbox item... Pin
kubben24-Jul-07 2:25
kubben24-Jul-07 2:25 
GeneralRe: disable a listbox item... Pin
shaz jazz26-Jul-07 22:18
shaz jazz26-Jul-07 22:18 
GeneralRe: disable a listbox item... Pin
kubben27-Jul-07 1:21
kubben27-Jul-07 1:21 
GeneralRe: disable a listbox item... Pin
shaz jazz27-Jul-07 2:11
shaz jazz27-Jul-07 2:11 
GeneralRe: disable a listbox item... Pin
kubben27-Jul-07 2:12
kubben27-Jul-07 2:12 
GeneralRe: disable a listbox item... Pin
shaz jazz27-Jul-07 2:51
shaz jazz27-Jul-07 2:51 
GeneralRe: disable a listbox item... Pin
kubben27-Jul-07 3:16
kubben27-Jul-07 3:16 
GeneralRe: disable a listbox item... Pin
shaz jazz27-Jul-07 3:37
shaz jazz27-Jul-07 3:37 
Questioni need a code for this please Pin
magedhv23-Jul-07 21:34
magedhv23-Jul-07 21:34 
AnswerRe: i need a code for this please Pin
Christian Graus23-Jul-07 22:21
protectorChristian Graus23-Jul-07 22:21 
GeneralHe doesn't listen Pin
leckey24-Jul-07 3:03
leckey24-Jul-07 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.