CREATING THE FIRST FORM

Interface with the user

The Form is the first object you work with in VB.

It is the primary interface with the user. It is used to input DVD rentals in the Video store application or customer data in your on-line Dating Service.

The form can even be your game surface if you're learning programming with the hope of becoming the next great game designer.

When you design the form you have to take into account the user's requirements - the video rental store will have a different operating environment from the online pharmacy or the poker game you're creating. For example, any kind of game will probably require timers but most business applications never use them.

Before you even begin to work in VB, you should take a few minutes to think about the layout of the form. You can even draw a sketch of what you expect to produce. You will identify the size of the objects, the placement, the colors.

Setting-up the environment

When you install Visual Studio .Net, all the default options are usually pretty much set for you.

There are a couple of options you may wish to look at.










Simple controls

Start with a blank form.

Draw a label on the form. Then add a button and another label.

Now, you're working with 4 objects: the form, 2 labels and a button.

The first, and easiest thing to change is the color of all the objects.
So, you click on an object to select it and you go over to the Properties window and select a color for Backcolor.
Do this for all 4 objects.





Common properties

Some of the properties are common to most objects. These are the ones you normally set at design time.

Running the application

If we want the app to do something, we have to program it, ie: write code.

In VB, the app is event-driven - the code is executed when some event occurs. In this case, the event is the Click of a button.

To get an idea of how this works, double-click Button1. This will open the code editor and will generate a subroutine. The Sub is identified by the first line of Private Sub ..... and ends with Ens Sub.

Then, write the code shown inside the Sub.




Or, download the sample containing what we've done so far.

Just extract the application into your VB folder.

Lesson1





Visual Basic .Net for Rookies                vb .net