Beheld Basal .NET Variables

 30 July 14:34   

    In programing a capricious is artlessly a abode to abundance data. A capricious has a name and a data type. In Beheld Basal .NET, a capricious is declared using the Dim (short for Dimension) statement. Actuality is the syntax:

     Dim varName As varType

    varName is the name of your Variable.

    varType is the data blazon of the variable. Types cover string, integer, double, boolean, etc.

    For example, to acknowledge an accumulation called MyInt use:

     Dim MyInt As Integer

    Data Types ascertain the blazon of data that a capricious can store. Some variables abundance numbers, others abundance names. The basal types that can be acclimated in Beheld Basal .NET are:

    Meaning active byte (added in VB.NET 2005). 8 bits, food accumulation ethics from -128 to 127.

     Dim sbytMyVariable As SByte

    8 bits, food accumulation ethics from 0 to 255.

     Dim bytMyVariable As Byte

    Meaning abbreviate integer. 16 $.25 (2 bytes), food accumulation ethics from -32,768 to 32,767.

     Dim shrtMyVariable As Short

    Meaning bearding abbreviate accumulation (added in VB.NET 2005). 16 $.25 (2 bytes), food accumulation ethics from 0 to 65,535.

     Dim ushrtMyVariable As UShort

    32 $.25 (4 bytes), food accumulation ethics from -2,147,483,648 to 2,147,483,647.

     Dim intMyVariable As Integer

    Meaning bearding accumulation (added in VB.NET 2005). 32 $.25 (4 bytes), food accumulation ethics from 0 to 4,294,967,295.

     Dim uintMyVariable As UInteger

    Meaning continued integer. 64 $.25 (8 bytes), food accumulation ethics from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.

     Dim lngMyVariable As Long

    Meaning bearding continued accumulation (added in VB.NET 2005). 64 $.25 (8 bytes), food accumulation ethics from 0 to 18,446,744,073,709,551,615.

     Dim ulngMyVariable As ULong

    Meaning single-precision amphibian point. 32 $.25 (4 bytes), food floating-point ethics from -3.40282347e38 to 3.40282347e38. Cannot abundance an exact aught due to the appropriate normalized form. Aboriginal absolute amount greater than aught is 1.401298e-45. Better abrogating amount beneath than aught is -1.401298e-45.

     Dim sglMyVariable As Single

    Meaning double-precision amphibian point. 64 $.25 (8 bytes), food floating-point ethics from -1.7976931348623157e308 to 1.7976931348623157e308. Cannot abundance an exact aught due to the appropriate normalized form. Aboriginal absolute amount greater than aught is 4.94065645841247e-324. Better abrogating amount beneath than aught is -4.94065645841247e-324.

     Dim dblMyVariable As Double

    128 $.25 (16 bytes), food floating-point ethics from -79,228,162,514,264,337,593,543,950,335 to 79,228,162,514,264,337,593,543,950,335. Food an exact zero.

     Dim decMyVariable As Decimal

    Requires 1 bit (1 byte used), food boolean true/false values. For a false value, one may access false or 0 in the antecedent code; for a true value, access true or -1.

     Dim boolMyVariable As Boolean

    64 $.25 (8 bytes), food a date and time in the ambit of January 1, 0001 12:00:00 AM to December 31, 9999 11:59:59 PM.

     Dim dtMyVariable As Date

    16 $.25 (2 bytes), food one unicode attribute in the ambit of 0 to 65,535.

     Dim chMyVariable As Char

    10 bytes + argument breadth (maximum total: 2GB), food any alternation of characters. e.g. word, phrase, sentence, paragraph, etc.

     Dim strMyVariable As String

    32 $.25 (4 bytes), food a advertence to a Beheld Basal object.

     Dim objMyObject As Object

    A amount is the data independent in a variable.

    To accredit a amount to a capricious that is already declared, use an according sign.

    Integral literals, such as 42 and 1000, are of blazon Integer by default. Cord and appearance literals, such as Hello World and A, are of blazon String by default. To specify the blazon for a literal, suffixes are used. The suffixes are added anon afterwards the literals, in the address <literal><suffix>, after any whitespace between.

    For cord and burn variables, use bifold quotes about the value:

     strMyVariable = The String

     chrMyVariable = Ac

    For date variables, use hashes/pounds about the value, in the architecture #<month>/<day>/<year> <hour>:<minute>:<second> <AM|PM>:

     dtMyVariable = #7/4/1776 12:01:50 PM

    For all others, abolish the quotes and hashes/pounds:

     bytMyVariable = 1

     sbytMyVariable = -2

     shrtMyVariable = 10S

     ushrtMyVariable = 10US

     intMyVariable = 100

     uintMyVariable = 100UI

     lngMyVariable = 1000L

     ulngMyVariable = 1000UL

     sngMyVariable = 1.234F

     dblMyVariable = 1.567R

     decMyVariable = 1234567.89D

     boolMyVariable = True

     objMyObject = New Object

    To accredit a capricious the amount of addition variable, artlessly alter the amount on the appropriate ancillary of the according assurance with the name of the capricious that holds the adapted data.

    Important: Beheld Basal consistently assigns the amount of the appropriate capricious to the larboard variable. The capricious on the larboard takes the amount of the appropriate variable. The capricious on the appropriate does not change.

    Constants are like variables that dont change. They yield the abode of ethics that you would not like to blazon over and over. Constants are declared using the keyword Const. Their ethics are authentic in their acknowledgment - they aswell use data types.

    Here is the syntax:

     Const cnstMyConstant As String = The actual continued string

    Here is an example:

     Const cnstPi As Single = 3.14159265F

    

 


Tags: added, types, basic, point, store, value, greater, exact, declared, stores, values, string, false, short, positive

 stores, variable, integer, values, value, bytes, basic, string, variables, store, visual, point, floating, added, types, false, literals, declared, const, exact, unsigned, short, double, , bytes stores, values from, stores integer, integer values, visual basic, floating point, basic net, net 2005, variable the, exact zero, stores floating, integer added, point values, stores integer values, integer values from, bytes stores integer, point values from, floating point values, stores floating point, bytes stores floating, greater than zero, value greater than, biggest negative value, negative value less, value less than, positive value greater, required normalized form, precision floating point, bits stores integer, normalized form smallest, form smallest positive, smallest positive value,

Share Beheld Basal .NET Variables: Digg it!   Google Bookmarks   Del.icio.us   Yahoo! MyWeb   Furl  Binklist   Reddit!   Stumble Upon   Technorati   Windows Live   Bookmark

Text link code :
Hyper link code:

Also see ...

Permalink
Article In : Computers & Technology  -  Programming