Jump to content

VB.NET from beginner to advanced programmer Part 4 - The basic data types

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Welcome to the VB.NET tutorial series: "VB.NET from beginner to advanced programmer" which will take you from the very beginning to be a good programmer. VB.NET is a good first language for new programmers so this 21 part long series is written for completely beginners but it will also works perfectly fine if you already know another programming language.


VB.NET from beginner to advanced programmer




From the last part you learned that variables and constants use different types depending on what values that should stored in them. This Part will teach you the basic types so you know what to use.





Boolean

A boolean value is either True or False. Boolean values are important when using logical operators and relational operators(See part 5 and 6 for more info).


Integer

The Integer types can (of course) store Integer values. There is three sizes of Integers which all can be both Signed and Unsigned and can be written in to ways for a total of 12 "different" types.

Short or Int16
The smallest of them, can store values with a 65,535 long span.

Integer or Int32
The medium size , can store values with a 4,294,967,295 long span.

Long or Int64
The Largest of them all , can store values with a 18,446,744,073,709,551,615 long span.




By adding a "U" to them they become unsigned(UInt32,ULong etc.), When they are Unsigned the span starts from 0 and goes up, and when they are signed they have the half span below 0 and the other half above.

For example, Short(or Int16) has the span length 65,535.
If it's signed(Short or Int16) it has the span from -32,768 to 32,767.
And if it's unsigned(UShort or UInt16) the span goes from 0 to 65,535.





Single


The single type is a numeric type which can store decimals too. It can store values from 1.401298*10-45 to 3.4028235*1038 for both positive and negative values with a total of 7 decimal places.



Double


The type double, is also a numeric type with decimal places. The double can store bigger(and smaller) values then the Single. The span goes from -4.94065645841246544*10-324 through 1.79769313486231570*10308 for both positive and negative values. The Double can store a total of 15 decimals.



String

The string type can store text. To write a string you start with one double quote and end with another, like this:

Dim sMessage ="This is a string"

In a string variable you can store up to aproximatelly 2 billion(!) Unicode characters.


Char

Only stores one character, as with Strings you surrounds it by double quotes.


Now you should be able to use the basic types, see you in next part, Part 5.

Edited by Vswe, 21 March 2010 - 02:25 PM.


#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
Nicely done. +rep
Where is byte and long?

#3
Vswe

Vswe

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 9,552 posts
Long is there and I must have forgot to write about byte.