In this posting I'll write a sample of simple VB6 programme that using
Select Case..End Select control structure. However this programme also using several VB6 functions like
Val() (to convert text into number so can be calculated),
Len() (to get the length of a text) and
Left() (to pick up a part from the left side of a text).
The scenario of the programme is as the following:
This programme is Bonus Calculation (Sales System).
Here it is the bonus percentage table:Sales Quantity = 1 - 2 -> Bonus = 2%
Sales Quantity = 3 - 4 -> Bonus = 3%
Sales Quantity = 5 - 6 -> Bonus = 4.5%
Sales Quantity = 7 - 8 -> Bonus = 6.5%
Sales Quantity = 9 -> Bonus = 10%
Sales Quantity = 10 or more -> Bonus = 15%
Bonus Amount = Sales Quantity X Price Unit X Bonus
The screen design of the programme is like below screenshot.
Now, let's design the programme first (create screen interface).
Open your Visual Basic 6 software
Select a standard type project
Create 5 Labels
Create 4 Textboxes
Create a Command button
Arrange the controls on your Form like the picture above
Click first Label (Label1)
Rename the caption of Label1 into Bonus calculation
Change the font size into 24
Change the caption of Label2, Label3, Label4 and Label5 into Your Sales Quantity, Price Unit (USD), Percentage of Bonus, and Amount of Bonus (USD)
Click first Textbox (Text1), clear it's Text, and rename into txtSalQty
Click second Textbox (Text2), clear it's Text, and rename into txtPriceUnit
Click third Textbox (Text3), clear it's Text, and rename into txtBonus
Click fourth Textbox (Text4), clear it's Text, and rename into txtBonusAmt
Click Command1 button, change the caption into Calculate Bonus, and rename into cmdCalBonus
Click anywhere in Form1 area, and rename into frmCalBonus (look at properties window)
Click Project1 file (in Project explorer window)
Click cell next to (Name) in Properties Window, and change the Name into prjCalBonus
Look at image above, your screen design should like that.
Ok, now the time to save your work (your programme) in order you can edit it next time (this programme will be used in the next posting). Here it is tips to save your VB6 programme:
Click File menu on your menu bar
Click Save Project As... menu
On Save File As window, type frmCalBonus on the cell with label File name:
Select the folder you want to save in, then click Save button
Then on Save Project As window, Type prjBonus on the cell with label File name:
Then click Save button
Note: The extention .vbp and .frm will automatically given by the system.
Ok, now your programme has been saved. You have 2 files in your project: prjBonus.vbp and frmCalBonus.frm and you can close your VB programme. I'll continue to write the programme coding in the next posting.
3 comments:
I love to learn the VB but still I can't it's amazing isn't it??????
I love VB too, and built some small applications using it. And I also learn VB for fun.
i had learnt VB but facing some problems ...can you help
Cash Online Get Easy cash at your door step
Post a Comment