Computer Science, asked by alurushareef5030, 10 months ago

Write the various rules to follow to declare variable in vb

Answers

Answered by radhikaraj2215
0

Rules for naming variables in Visual Basic

Must be unique within scope

Must begin with a letter or the underscore _ character

May not contain embedded spaces or many special characters (. , “ - $ # * and others). The underscore _ is a valid character.

May not be a reserved word

In addition

Use upper and lower case with purpose. Once a variable is declared you do not have to be concerned with upper/lower case. The editor recognizes words that are the same except for case and makes them all the same for you. (use of upper and lower case differ between languages)

It is good programming practice in any language to use naming conventions (rules, standards) to name your variables. In Visual Basic the naming conventions include using a prefix that identifies the variable’s data type.

intNumber The prefix int would signify an integer variable

decHours The prefix dec would signify an Decimal variable, use sng for Single and use dbl for Double

strName The prefix str would signify a string variable

blnYearEnd The prefix bln would signify a Boolean variable

 

By default it is REQUIRED to declare variables before you use them. If you do not declare variables an error --- Name 'xxx' is not declared will be reported. However it is not syntactically required that you indicate a data type. In this class you must declare the data type when you declare the variable.

It is not a violation of the rules of the language to declare more than one variable on the same line

Similar questions