Vb why is it dim




















Dim [one long and strange! If the As clause is not used, the type of the variable can be specified by using a type character as a suffix to variableName. The two different type-specification methods can be intermixed in a single Dim statement although not on the same variable.

Basic is a strongly typed language: variables must be given a data type or they are assigned the data type variant. The available data types are:.

For details on these variable types, read VB Data Types. NOTE: Good programming practice is to declare every variable. To force variables to be explicitly declared, use the Option Explicit statement read Option Explicit Statement. Place procedure-level Dim statements at the beginning of the procedure. Variables can be shared across modules. A variable declared inside a procedure has scope local to that procedure.

A variable declared outside a procedure has scope local to the module. If you declare a variable with the same name as a module variable, the module variable is not accessible. For details, read Global Statement. The Shared keyword is included for backward compatibility with older versions of Basic. It is not allowed in Dim statements inside a procedure. It has no effect. Regardless of which mechanism you use to declare a variable, you can choose to use or omit the type character when referring to the variable in the rest of your program.

The type suffix is not considered part of the variable name. CAUTION: You can declare several variables on one line; however, unless you include the type for each variable, the type applies only to the last variable declared. For example, Dim Acct, CustName, Addr As String causes only Addr to be declared as type string; the other variables are implicitly declared as type variant.

The available data types for arrays are numbers, strings, variants, and records. Arrays of arrays and objects are not supported. Array variables are declared by including a subscript list as part of the variableName. Initially, it was short for "dimension", which is not a term that is used in programming outside of this specific keyword to any significant degree. Back in the day DIM reserved memory for the array and when memory was limited you had to be careful how you used it.

Short for Dimension. It's a type of variable. You declare or "tell" Visual Basic that you are setting up a variable with this word. For reference type, we have to use new keyword to create the new instance of the class or structure. Dim lblTop As New System. Dim statement can be used with out a datatype when you set Option Infer to On. In that case the compiler infers the data type of a variable from the type of its initialization expression.

Example :. How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Collectives on Stack Overflow. Learn more. Ask Question. Asked 12 years, 4 months ago. Active 6 months ago. Viewed k times. What does Dim stand for in Visual Basic? Improve this question. Software Engineer Nick Katsivelos Nick Katsivelos 4, 4 4 gold badges 18 18 silver badges 11 11 bronze badges.

Add a comment. Active Oldest Votes. Improve this answer. In early releases of basic the only variables that needed to be declared were arrays. The "Dim" keyword was used to set the dimensions of this array.

I remember reading a gw-basic programming guide in the early 80's and I explicitly remember it explaining DIM meaning Declare In Memory. One thing to keep in mind is that, in early language development, it was common to overload a keyword to have multiple meanings.

We have already discussed various data types. The basic value types provided in VB. Net also allows defining other value types of variable like Enum and reference types of variables like Class. We will discuss date types and Classes in subsequent chapters. The Dim statement is used for variable declaration and storage allocation for one or more variables. The Dim statement is used at module, class, structure, procedure or block level. Shared declares a shared variable, which is not associated with any specific instance of a class or structure, rather available to all the instances of the class or structure.

Shadows indicate that the variable re-declares and hides an identically named element, or set of overloaded elements, in a base class. Static indicates that the variable will retain its value, even when the after termination of the procedure in which it is declared.



0コメント

  • 1000 / 1000