Paul The Programmer

North East Software and Websites

60 Second Blog

Lesson 4. Whats all this Sub business ?

Posted at 09:17 AM on December 23, 2008

As you saw during Lesson 3, a program looks a lot like (actually just like) this...

 

Sub AuntMarysBloomers()

 

MsgBox ("Aunt Mary wears bloomers")

 

End Sub

 

The Sub part acts as a nice neat container for the 'to do' list. We always have to contain the list, otherwise it might run off the screen and get married. Sub is a shortened version of Subroutine (code is nearly all about short things, my wife entirely understands short).

 

A Sub always ends in an End Sub, otherwise it wouldn't know when to stop. I would have just said ?when the code runs out? but apparently Microsoft never thought of it.

 

There is another container called Function that we'll come to later. Strangely, they didn?t shorten it to Fun, I think that might have been more accurate.

 

A Sub always needs a name, or it would never know when to do its job. In this case we called it AuntMarysBloomers. The name can be almost anything you like except for words the computer already uses to do other things. Do not panic. If the computer doesn't like your word it will let you know by not running your code.

 

 The brackets ( () ) are containers too. They can hold information (often known as gibberish) that we can get the code (we tried to write) to work on.

 

Confused? Me too. Time for a coffee, doughnut and a lie down by now. Just let it sink in slowly, we have a long way to go.

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