Paul The Programmer

North East Software and Websites

60 Second Blog

Lesson 9. More variables than a Unicycling Juggler

Posted at 11:13 AM on December 29, 2008

In an earlier lesson we met with Mr Integer, the variable for carrying around whole numbers. In this lesson, I thought it about time I showed you a number of other variable types which carry around values you’ll more than likely want to store and certainly need in your future code.

 

Firstly, we have the string, which keeps a track of characters, such as names, addresses, zip codes, product descriptions, she is allocated like this

 

Dim strIsPaulSexy as String

strIsPaulSexy = “NO, Paul has no sex appeal”

 

 

if we print out the value of strIsPaulSexy, the computer will tell us NO, Paul has no sex appeal – yeah, thanks a lot.

 

Then we have Mr Double. He can hold floating point numbers, which are numbers with a decimal place, like Pi or the money in your bank account

 

Dim dblPi as Double

dblPi = 3.14159265

MsgBox (dblPi * 10 & “cm”)

 

Run this code and you will get a message box showing you the circumference of a 10cm diameter circle. Remember the difference between an integer and a double. Integers will round up or down to the nearest whole number (e.g. 3.14.. = 3,  or 4.501 = 5)

 

Then there is the Gemini like Boolean, the True/False variable of two halves. Useful as a switch within our code, making something happen in one position, or ignoring the instructions in another perhaps.

 

Dim boolIsPaulSexy as Boolean

boolIsPaulSexy = False

 

If boolIsPaulSexy = True Then

    MsgBox (“Paul has sex appeal”)

End If

 

The computer, like most ladies, will say nothing.

Categories: VBA Tutorials (mixed nuts)

Post a Comment

Already a member? Sign In

0 Comments

Dont Miss a thing.

Get FREE updates from me by email. Get a mini profile that lives on my website. Learn and teach. Communicate and share ideas with other members. Join here.

Recent Blog Entries

by paultheprogrammer | 0 comments
by paultheprogrammer | 1 comments
by paultheprogrammer | 0 comments
by paultheprogrammer | 2 comments

Recent Forum Posts

by paultheprogrammer over a year ago

Recent Videos