The Data types available in VB .NET, their size, type, description are summarized in the table below.
Data Type | Size in Bytes | Description | Type |
Byte | 1 | 8-bit unsigned integer | System.Byte |
Char | 2 | 16-bit Unicode characters | System.Char |
Integer | 4 | 32-bit signed integer | System.Int32 |
double | 8 | 64-bit floating point variable | System.Double |
Long | 8 | 64-bit signed integer | System.Int64 |
Short | 2 | 16-bit signed integer | System.Int16 |
Single | 4 | 32-bit floating point variable | System.Single |
String | varies | Non-Numeric Type | System.String |
Date | 8 | /td> | System.Date |
Boolean | 2 | Non-Numeric Type | System.Boolean |
Object | 4 | Non-Numeric Type | System.Object |
Decimal | 16 | 128-bit floating point variable | System.Decimal |
Access Specifiers
Access specifiers let's us specify how a variable, method or a class can be used. The following are the most commonly used one's:
Public: Gives variable public access which means that there is no restriction on their accessibility
Private: Gives variable private access which means that they are accessible only within their declaration content
Protected: Protected access gives a variable accessibility within their own class or a class derived from that class
Friend: Gives variable friend access which means that they are accessible within the program that contains their declaration
Protected Friend: Gives a variable both protected and friend access
Static: Makes a variable static which means that the variable will hold the value even the procedure in which they are declared ends
Shared: Declares a variable that can be shared across many instances and which is not associated with a specific instance of a class or structure
ReadOnly: Makes a variable only to be read and cannot be written
Variables
Variables are used to store data. A variable has a name to which we refer and the data type, the type of data the variable holds. VB .NET now needs variables to be declared before using them. Variables are declared with the Dim keyword. Dim stands for Dimension.
Example
Imports System.Console
Module Module1
Sub Main()
Dim a,b,c as Integer
'declaring three variables of type integer
a=10
b=20
c=a+b
Write("Sum of a and b is" & c)
End Sub
End Module
No comments:
Post a Comment