1 / 18

VB02

VB02. Programming Concepts Variables. Variables. 23. Variables are virtual boxes that hold pieces of information Variables are referred to by their names. Age. Variable Types. There are different types of variables Different types of variable boxes hold differet types of data.

dominy
Download Presentation

VB02

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. VB02 Programming Concepts Variables

  2. Variables 23 • Variables are virtual boxes that hold pieces of information • Variables are referred to by their names Age

  3. Variable Types • There are different types of variables • Different types of variable boxes hold differet types of data

  4. Variable Types 37.56 • Some variables hold number • Some variables hold letters 21 “Robert” price Vat rate name

  5. Boolean Byte Currency Date Decimal Double Integer Long Object Single String Variant Visual Basic Variable Types

  6. Variable Names • In general you can call variables whatever you like • Most programming languages have restrictions on the names (e.g.must start with a letter) • VB recommend prefixes for variable names to make life easier

  7. Boolean bln Byte byt Currency cur Date dte Decimal Double dbl Integer int Long lng Object obj Single sng String str Variant vnt or var Visual Basic Variable Type Prefixes (by convention)

  8. Boolean • Named after George Boole • Can hold TRUE or FALSE • That’s all! • E.g. blnLight

  9. Byte • Positive number between 0 and 255 • e.g. bytNumStudents • e.g. 36 • e.g.0 • e.g. 200 102

  10. Integer • Whoel number between –32768 and 32767 • Not decimals • e.g. intNumCars • e.g. 9346 • e.g. –703 • e.g. 32000 21056

  11. Long • Whole number between –2147483648 and 2147483647 • e.g. lngNumPeople • 2 000 000 067 • -2 000 000 000 • 45 • -6 2836475

  12. Decimal • Numbers with 28 decimal places • Limited support for this type in VB • Best to use Single instead • e.g. 35.5768455465 • e.g. 7.57846354869 12.457

  13. Currency • Money amounts from -$922 337 203 685 477.5808 to $922 337 203 685 477.5807 • e.g. curLotto • Used exclusively for money • VB looks after the formatting based on local currency settings

  14. Single • Numeric value from -3.402823E+38 to 3.402823E+38 • Decimal numbers in scientific notation • e.g. sngAtomMass

  15. Date • Date & Time value from 1 Jan 0100 to 31 Dec 9999 • In a variety of formats • e.g. dteBirthday • VB looks after the formatting based on local preferences • e.g. 22:35 17 Jan 2002

  16. Double • Just like single only more precice • Allows for bigger numbers • -1.76769313486232E+308 to 1.76769313486232E+308 • e.g. dblElectronMass

  17. String • Used to store characters (letters, numbers, symbols) • Up to 65 400 characters • Usually enclosed in quotes • e.g. strName • e.g. “Hello!” • e.g. “Cork” España ¡Hola! 1271 Rossa Ave.

  18. Variant • Used to hold things when you don’t kow what hey are • Usually a bad idea • You should knw • We won’t use this type in this course

More Related