VB.Net Data Types and variable Declaration with DIM

0
282

VB.Net Data Types and Variable Declaration with DIM

VB.Net Data Types refers to a type of data that any variable can store in vb.net. This variable belongs to different data types and determines how much space it occupies in storage memory allocated. VB.Net Data Types includes include the following.

What are Data Types in VB.Net?

VB.Net Data Types

  • Boolean

    The storage allocation depends on the implementing platform. The default values for VB.Net Data Type Boolean is TRUE or FALSE.

  • Byte

    Values range from 0 to 255 (unsigned).

  • Char

    Values range from 0 to 65535 (unsigned).

  • Date

    The storage space is 8 bytes. Values range from 0:00:00 (midnight) on January 1, 0001 through 11:59:59 PM on December 31, 9999.

  • Decimal

    The storage space is 16 byte. From 0 through +/-79,228,162,514,264,337,593,543,950,335 (+/-7.9…E+28) with no decimal point; 0 through +/-7.9228162514264337593543950335 with 28 places to the right of the decimal

  • Double

    -1.79769313486231570E+308 through -4.94065645841246544E-324, for negative values
    4.94065645841246544E-324 through 1.79769313486231570E+308, for positive values

  • Integer

    has a storage space of 4 bytes. Values range between -2,147,483,648 to 2,147,483,647 (signed).

  • Long

    It has a storage space of 8 bytes. From -9,223,372,036,854,775,808 through 9,223,372,036,854,775,807(signed)

  • Short

    It has a storage space of 2 bytes. -32,768 through 32,767 (signed)

  • Single

    It has a storage space of 4 bytes. -3.4028235E+38 through -1.401298E-45 for negative values;
    1.401298E-45 through 3.4028235E+38 for positive values

  • String

    The storage allocation depends on the implementing platform. Values from 0 to approximately 2 billion Unicode characters.

VB.NET Variables

What is a Variable? Variable is the most important in computer programming. All programming languages used variables to store and hold temporary data until it is released.

You will not appreciate the importance of variableS at this moment. But as you continue in programming you will realize what I’m talking about.

In declaring variables, the first thing that you have to do is to type the “Dim“.

See the Example below:

Here’s the example to display the value stored in a variable.

VB.Net Data Types and Variable Declaration with Dim in Actual Program.

In this section, we will now perform some of the most commonly used in the vb.net data type together with the use of vb.net variables using DIM for the declaration of VB.Net Variables.

Steps to Perform the VB.Net Data Types and variables

Step 1. Open Visual Studio and Create a new Project.

VB.NET Data Types and Variable Declaration with Dim Step 1

Step 2. Create a Windows Form Application. Follow the steps in the image below.

Step 3. Add a Button to Windows Form.

Step 4. Change the Text property of the button to “Test Variables”. Then Double click the Button and the Following Code.

The code above is only a variable declaration with Dim. Dim means Dimension. If you are going to read the declaration, you say “The Dimension of variable name as Data Type”.

Step 5. Assign a value to a VB.Net variable. Add the following code.

Step 6. Display the result of using Messagebox. Add the following code.

Step 7. Press “F5” to run the Project.

When you run the project and click the “Text Variable” button. you will see the following message box below.

Sample output of VB.NET using boolean

vb.net Boolean variable

Sample output of VB.NET using Date

vb.net Date variable

Sample output of VB.NET using Integer

vb.net Integer variable

Sample output of VB.NET using Decimal

vb.net Decimal variable

Sample output of VB.NET using String

vb.net String variable

Summary

In summary, we have tackled VB.Net Data type and learn what would be the possible value of different data types when assigning to a specific vb.net variable.

For more examples, you may visit it guru99.com.

Inquiries

If you have any questions or suggestions about this tutorial, please feel free to leave a comment below.

This tutorial is the continuation of our previous tutorial entitled VB.NET Tutorials for Beginners with Examples.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.