Visual Basic Programming

1 Conversation

Introduction


The Visual Basic programming language (or VB, as the pros call it) is a language developed by Microsoft, a part of their Visual Studio family of programming languages. As the name suggests, it is very similar to to the original BASIC1 language2, but it is Object Orientated3, unlike the original BASIC language. Also, as the other part of the name suggests, you don't have to worry about the graphical side of the program4 when you are programming, as the compiler does it all for you.

The flavours of Visual Basic


Currently, there are three main 'flavours' of the Visual Basic programming language:
  • The full blown programming product
  • Visual Basic for Applications (VBA)
  • Visual Basic Script


Essentially, they are all the same language, but each of them have slightly different purposes. The full blown programming product is used for making standalone programs (like Microsoft Word, Excel, etc.) Many Microsoft programs now offer the ability to program in VBA to make repetitive tasks easier. You can write short programs (called Macros) to do number crunching, and other boring jobs; and finally, VBScript is a scripting language (a bit like JavaScript), used for programming browser based applications. VBScript is a rather cut down version of the full Visual Basic language, but it has the advantage that, if you know VB, you can take up VBScript very easily.

Learning Visual Basic

Is it easy to learn?


VB is easy to learn, in that it is closer to human language than other programming languages such as C. In fact, the code bears some kind of resemblance to English, whereas languages like C and Java look quite frightening at first sight.


Look at this example of some VB code:

If number<7 Then
      TextBox.text="Number is smaller than 7"
Else
      TextBox.text="Number is bigger or equal to 7"
End If


... and compare with this C code which (nearly) does the same thing:

if (number<7)
{
      printf("number is smaller than 7");
}
else
{
      printf("number is bigger or equal to 7");
}

OK, so where do I start?


There are many excellent books out there which teaches you Visual Basic, but they tend to be rather costly. The IDE5 for VB costs a lot in itself, and the chances are that you wouldn't want to spend more money on expensive books. Well, HELP is at hand! Use the Help files which came with your copy of Visual Basic.
Now, this may seem like a stupid suggestion, as Help files don't tend to be particularly user-friendly, but atleast it comes to the point, unlike some books in which the author rambles on about the last time he did this, and the last time he did that, etc.... you know the type. Infact, I learnt Visual Basic from helpfiles alone.6The later versions of Visual Basic (I think from version 5 onwards) also comes with a nice manual called Visual Basic Books Online, which has a more tutorial-like approach.

The Basics Of Visual Basic


OK, so I can't teach you the whole of Visual Basic on this page alone (I wouldn't have the patience to anyway), but, here is a taster. I am assuming that you have got a copy of Visual Basic (if you don't, then you can't do anything).

Hello World (or Universe, or Life, or Everything, depending on your mood)


So, let's start with what all programmers start with: The legendary 'Hello World Program'. All this does is to write 'Hello World', anywhere on the screen. The point of it is to introduce the programmer to the new programming language. So, here it goes:

  1. Open up Visual Basic. You should be greeted with a blank form
  2. Make a textbox (Click on the textbox button on the toolbox, and draw a rectangle on the blank form)
  3. Make a button (in the same way as the textbox, but click the 'Command Button' button on the toolbox instead)

    Double click the button.
  4. Type the following code in between 'Sub ....' and 'End Sub':


    text1.text="Hello World"


  5. Close the code window
  6. Click the 'RUN' button on the toolbar at the top
  7. Click the button on the form

The text box should display 'Hello World'

Where do I go from here?


Well, you are now free to do anything you want (well, not quite anything). Here are some sites which may be of use:

Microsoft Developer Networkhttp://msdn.microsoft.com
A1VBCodehttp://www.a1vbcode.com
VB Wirehttp://vbwire.com/
VB CodeGuru
http://codeguru.developer.com



The best way to learn is to explore, so go ahead! And Bon Chance
1which stands for: Beginners' All-purpose Symbolic Instruction Code: it was developed by the US military, years before the personal computer2Infact, Bill Gates (the Chairman of Microsoft) and his friends, wrote a BASIC interpreter for many of the early computers, but in those days, as processing power was limited, languages like BASIC (a rather 'wordy' language) were rather slow compared to languages like C (which uses a lot of symbols). 3Object Orientated Programming languages are often called OOP: OOP is a class of languages in which the pieces of code are broken up into blocks, called methods, which allows code to be 'reused', and makes maintaining easier. See Webopedia: OOP4well, atleast the implementation of it. You still have to design the Graphical User Interface (GUI - another jargon)5Integrated Development Environment: the program which makes life easier for programmers by putting all the tools in one place, and doing a lot of the ugly work6Well, that's not quite true; I had some help from the internet (which, by the way, is also a good place to learn Visual Basic)

Bookmark on your Personal Space


Conversations About This Entry

Entry

A479199

Infinite Improbability Drive

Infinite Improbability Drive

Read a random Edited Entry


Written and Edited by

Currently in:

References

External Links

Not Panicking Ltd is not responsible for the content of external internet sites

Disclaimer

h2g2 is created by h2g2's users, who are members of the public. The views expressed are theirs and unless specifically stated are not those of the Not Panicking Ltd. Unlike Edited Entries, Entries have not been checked by an Editor. If you consider any Entry to be in breach of the site's House Rules, please register a complaint. For any other comments, please visit the Feedback page.

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more