In this tutorial I will show you how to make 3 different kinds of calculators. This is recommended for people who know the basics of VB6.
Let me introduce myself, I'm Zachafer. Call me Zach. I like programming and helping others. I post screenies of most of the steps to make it easier. Here it goes.
--- 1. Let's Start off by opening up VB6.
2. We are now at the main form.
Now we want to add the User Interface.
Let's add:
- A ComboBox named cmboChoose
- A Command Button named cmdAdvanced (Caption = Advance)
- A Timer. Leave the name as Timer1 (Timers are never visible when running a program)
- Change the Form's name to frmSplash. (Form Caption = Choose Calculator)
This is our splash screen.
--- 3. Time to Code the Splash Screen
Coding the Splash screen is simple.
I will go through the code with you.
Using ' in code means that the green text is notes and do not play a role in the program.
Here is the code:
Code:
Option Explicit
Option Explicit 'i just put this in my codes. makes me feel better
Private Sub cmdAdvance_Click() 'this means that it will do the following events when cmdAdvance is clicked
If cmboChoose.Text = "Triangular Area Calculator" Then 'checks if user selected Triangular Area Calculator
Me.Hide ' if the user did want triangular area calculator then frmSplash will not be visible
frmTri.Show 'and frmTri will be visible
End If 'closes the if
If cmboChoose.Text = "Rectangular Area Calculator" Then 'sees if user wants rectangular area calculator
Me.Hide 'if they do then frmSplash will hide
frmRec.Show ' and frmRec will show
End If
If cmboChoose.Text = "Rectangular Solid Volume Calculator" Then 'sees if user wants to use the volume of a rectangular solid calculator
Me.Hide 'if they do then frmSplash will hide
' (you could also use:
'me.visible = false)
frmVol.Show
'could also use:
'frmVol.visible = true
End Sub
Private Sub Form_Load() 'these events will happen on form load
cmboChoose.AddItem ("Triangular Area Calculator") 'adds item to cmbChoose
cmboChoose.AddItem ("Rectangular Area Calculator") 'adds item to cmbChoose
cmboChoose.AddItem ("Rectangular Solid Volume Calculator") 'adds item to cmbChoose
End Sub
Private Sub Timer1_Timer() 'this is the timer's events
frmSplash.Caption = Time 'this will make frmSplash's Caption the system's time.
'pretty simple. you can use for anything.
'you could use:
'me.caption = time
End Sub
--- 4. Time to Move On!
Now that we have our Splash form done, let's move onto frmTri.
Here's what YOU need to do:
- Create 3 labels. Names do not matter. (Captions: Base, Height, Area)
- Create 3 textboxes. Names: txtBase, txtHeight, txtArea
- Create 1 Command Button Named cmdCalculate. (Caption = Calculate)
- Change Form's Name to frmTri (Caption = Triangular Area Calculator)
You need to know the formula to find the area of a triangle.
The area is Base * Height / 2
Now for the code: (commented, indented, explained)
Code:
Private Sub cmdcalculate_Click() 'these events happen when cmdcalculate is clicked
Dim intBase As Integer 'tells VB we want
Dim intHeight As Integer ' 3 integers.
Dim intAnswer As Integer 'also tells names
intBase = txtBase.Text 'tells VB that intbase is whatever is entered in txtBase
intHeight = txtheight.Text 'tells vb that intHeight is whatever is entered in txtHeight
intAnswer = intBase * intHeight / 2 'tells VB that intanswer = intbase * intheight divided by 2
txtArea.Text = intAnswer 'tell VB to make txtArea's text to be intAnswer
End Sub --- 5. Keep Moving Forward!
We are making great progress. Next let's make the Rectangular Area Calculator.
You need to:
- Create 3 Labels. Names do not matter. (Captions = Length: Width: and Area

- Create 3 TextBoxes. Names: txtLength txtWidth and txtArea.
- Create 1 Command Button. Name: cmdCalculate (Caption = Calculate)
- Change the Form's Name to frmRec (Caption = Rectangular Area Calculator)
Now add the explained, commented, and indented code:
Code:
Private Sub cmdCalculate_Click()
Dim msgboxthing As VbMsgBoxResult 'just the usuals.
Dim intLength As Integer
Dim intWidth As Integer
intLength = txtLength.Text ' tells VB what the integers are.
intWidth = txtWidth.Text
txtArea.Text = intLength * intWidth
msgboxthing = MsgBox("Want to Find the Volume?", vbYesNo + vbQuestion + vbDefaultButton2 + vbSystemModal, "Volume?")
'gives the user a message box.
If msgboxthing = vbYes Then 'if the user pushed yes then show volume calculator
Me.Hide ' hides frmRec
frmVol.Show 'show frmVol
ElseIf msgboxthing = vbNo Then 'if the user picks no, then...
Me.Hide 'hides frmRec
frmSplash.Show 'shows frmSplash
End If
End Sub
--- 6. You are Getting the hang of this!
Last Form. You need to:
- Create 3 Labels. Names do not matter. (Captions = Area: Height: Width

- Create 3 TextBoxes. Names: txtArea txtHeight txtVol
- Create 1 CommandButton Named cmdCalculate. (Caption = Calculate)
- Change the Form's Name to frmVol (Caption = Rectangular Solid Volume Calculator)
Here is the explained, indented, commented, and last code:
Code:
Private Sub cmdCalculate_Click() 'events will happen when cmdCalculate is clicked
Dim strArea As String 'tells vb what we want to be strings and integers
Dim intHeight As Integer
strArea = txtArea.Text 'tells vb the values
intHeight = txtHeight.Text
txtVol.Text = strArea * intHeight
End Sub
Private Sub Form_Load() 'these events happen when the form loads
MsgBox ("This Finds the Volume of Rectanular Solids") 'displays a messagebox
End Sub
--- Credits:- Me - for making this 100%.
- ImageShack.us - for hosting the screenshots.
- Jesus Christ - for being #1.
