Tuesday, April 13, 2010
8 Basic Steps to Create a Program in Visual Basic
Visual Basic is one of even-driven programming. Creating an even-driven programs like Visual Basic requires different approach from that used in procedural languages. The approach may seem unusual, if you are experienced with procedural programming.
Here are 8 basic steps in creating an application with Visual Basic:
1. Create a Design Plan
2. Create the user interface
3. Set the properties of interface objects
4. Write code for events
5. Save the project
6. Test and debug the application
7. Make an executable file (by compiling it)
8. Create a setup application
Labels:
VB6 Programming Tips
Friday, April 9, 2010
How to Name Objects in VB6 Programming ?
When an object is created, a default name based on its object typed will be given to the object. For example Form1 will be given to object/control with type Form, Text2, Text3,... will be given to Textbox object, Command1, Command2,.... will be given to command button object. You should immediately change the name property of the object to a name that describes the purpose of the control. Changing the Name property of your object with a name that describe the purpose with the object will make the code in your application easier to read and debug.
Visual Basic has several Standard Naming Convensions. Although you can assign any name you want to an object, but it is a better to adopt a naming convension and use it ocnsistently throughout your programms. Because it will make easier for others to understand your code.
Here it is a list of Standard Naming Convensions used in Visual Basic that assign to each type object:
The prefix you should use: chk
Example name: chkDrink
The prefix you should use: cbo
Example name: cboStore
The prefix you should use: cmd
Example name: cmdSelect
The prefix you should use: dat
Example name: datSales
The prefix you should use: dir
Example name: dirImage
The prefix you should use: drv
Example name: drvSource
The prefix you should use: fil
Example name: filSource
The prefix you should use: frm
Example name: frmEntry
The prefix you should use: fra
Example name: fraOption
The prefix you should use: grd
Example name: grdItem
The prefix you should use: hsb
Example name: hsbTemperature
The prefix you should use: img
Example name: imgEmployee
The prefix you should use: lbl
Example name: lblName
The prefix you should use: lin
Example name: linHorizontal
The prefix you should use: lst
Example name: lstCustomer
The prefix you should use: mnu
Example name: mnuReport
The prefix you should use: ole
Example name: oleObject2
The prefix you should use: opt
Example name: optCountry
The prefix you should use: pic
Example name: picFlower
The prefix you should use: shp
Example name: shpSquare
The prefix you should use: txt
Example name: txtName
The prefix you should use: tmr
Example name: tmrStep
The prefix you should use: vsb
Example name: vsbRate
Labels:
VB6 Programming Tips
Saturday, April 3, 2010
How to Return Property Values in VB6 Programming?
It is often needed to return property value of an object to perform a calculation or some other task in your Visual Basic Application. And in the most previous sample program I've written use this way to perform some calculations, and also some other tasks. For example in the sample program of How to Convert Degree from Celcius to Another in VB 6 Programming? also returning property value to be calculated, and then the result of calculation to set the property value of other object.
To return the value of an object property, you can use below syntax:
Variable = Object.Property
Or
Object2.Property = Object1.Property
Note:
You can use the first syntax if you want to return the value of an object property into a variable, so the value will be kept in the variable.
You should use the second syntax if you want to return the value to set another object property value.
In the most sample program I've written in the previous postings use the second syntax to return value of an object property and perform the calculation, then the result kept as value of another object property.
Notice below sample code:
Text2.Text = Val(Text1.Text) * 1.8 + 32
The value of Text1.Text is returned and used as an operand in the calcuation phrase and the result of calculation then used as value of Text2.Text. In this example you don't need a variable to keep the calculation result.
Another example code:
strName = txtName.Text
lblName.Caption = txtName.Text
Any comment? Please leave it in the below comment box.
Labels:
VB6 Programming Tips