3. Project using Combo Box:
In this project we use 3 combo boxes to
set different values for principal, ratepercent and years and compute simple
and compound interest for the different sets of values. Drag
7 command buttons, 7 labels, 2 text boxes and 3 combo boxes in the form,
size them caption them and position them as shown in the figure 8. The different sets of values for principal,
ratepercent and years can be added either at design time or during run
time. If you want to add items during design
time, set the list property. Check list in the property box, then add items,
pressing ctrl + enter after each item.
To enter items at run time you have to write codes. Items that are selected in the combo boxes
can be deleted by the delete buttons..
Open the code window and enter the codes as shown in the figure 8a. Save and run the project and experiment
with the different controls. A typical
run mode window is shown in the figure 9.

Figure 8
Private
Sub Command1_Click()
Text1.Text
= Combo1.Text * Combo2.Text * Combo3.Text / 100
Text2.Text
= Combo1.Text * (1 + Combo3.Text / 100) ^ Combo2.Text - Combo1.Text
End
Sub
Private
Sub Command2_Click()
principal
= InputBox("enter principal to be added")Combo1.AddItem principal
End
Sub
Private
Sub Command3_Click()
Combo1.RemoveItem
Combo1.ListIndex
End
Sub
Private
Sub Command4_Click()
ratepercent
= InputBox("enter ratepercent to be added")
Combo3.AddItem
ratepercent
End
Sub
Private
Sub Command5_Click()
years
= InputBox("enter years item to be added")
Combo2.AddItem
years
End
Sub
Private
Sub Command6_Click()
Combo2.RemoveItem
Combo2.ListIndex
End
Sub
Private
Sub Command7_Click()
Combo3.RemoveItem
Combo3.ListIndex
End
Sub
Private
Sub Command8_Click()
Text1.Text
= principal * ratepercent * years / 100
End
Sub
Private
Sub
Form_Load()
Combo1.AddItem
500
Combo1.AddItem
600
Combo1.AddItem
700
Combo2.AddItem
2.5
Combo2.AddItem
3.5
Combo3.AddItem
7.5
Combo3.AddItem
12.5
End
Sub

Figure 9
Summary:
In
this lesson we have described some three
projects and learnt a few things about ActiveX controls and their
uses. In the next lesson we will
consider some more ActiveX Controls.
   |