In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly shows you "what is the use of VB.NET variables", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of VB.NET variables" this article.
The VB.NET variable is used to store the data that needs to be processed in the program, and the user can think of the variable as a box for storing data in memory. In other programming languages, almost all programmers are required to define the data types of variables before using variables, because variables of different data types require different memory space: for example, byte variables need 8-bit space, short integer variables need 16-bit space, etc., which means that the capacity of the box is different. So variables defined for one data type cannot hold the values of another data type.
In VB.NET, there are two ways to create variables: one is to use the Dim keyword, which is explicitly defined. You can also use the implicitly defined method of writing out a VB.NET variable and assigning a value to it directly when the user needs to use it.
With such a statement, a variable named x is created. You can also define more than one variable at a time using the following methods:
Dim a,x
This statement creates two variables: an and x.
Here, there are the following points to explain:
(1) how to name a variable. VB.NET, like other languages, must have variable names that begin with a letter, contain only letters, numbers, and underscores, and are not VB.NET keywords. When naming a variable, it is recommended that you do not use incomprehensible variable names such as an or x, but use a lowercase prefix with a specific descriptive name, which is called the Hungarian method. The first three letters of the variable name are used to describe the data type, and the fourth letter is capitalized to indicate the actual meaning of the variable. For example, the following definition:
Dim strFileName Dim intTotal
It can be said that the variable names are well defined: using the combination of str and FileName to indicate that strFileName is used to store file names of string types, and using the combination of int and Total to indicate that intTotal is used to store the sum of integer types. Of course, this naming convention is not mandatory for programmers, and you can still use variable names such as an and x, or you can use the intTotal variable to store a string. But it is clear that if users adopt this way of naming variables and follow this good habit in the programming process, it can make the program easy to read and reduce the chance of error.
In VB.NET, the common convention prefixes are shown in the following table
Data type
Prefix
Example son
Boolean
Bln
BlnYes
Byte
Byt
BytByte
Char
Chr
ChrChar
Date
Dat
DatDate
Double
Dbl
DblDouble
Decimal
Dec
DecDecimal
Integer
Int
IntTotal
Long
Lng
LngLong
Single
Sng
SngSingle
Short
Sho
ShoShort
String
Str
StrText
Object
Obj
ObjFileObject
Common variable naming conventions
(2) when using the Dim statement, you can add an as keyword after it to specify the data type of a variable. For example:
Dim intTatal as Integer
This statement means to create a variable of integer type named intTatal, which can be used to indicate what type of data a variable must hold. Although VB.NET does not force users to specify their data types when defining variables, it is recommended that users use this method to specify the data types of variables when writing programs, so as to reduce the possibility of program errors.
(3) although you can use implicit methods to create VB.NET variables, it is still recommended to use explicit methods to define variables for the reasons mentioned earlier.
(4) in VB.NET, it is case-insensitive, which means that the variable strFileName and the variable strfilename will represent the same variable.
The above is all the content of the article "what is the use of VB.NET variables?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.