Go Back   Gaming Gutter > Non-Gaming > Programming > Tutorials


Tutorials - Looking for programming tutorials to increase your knowledge? Do so here.

» Site Navigation
» Home
» FAQ
» Log in
User Name:

Password:

Not a member yet?
Register Now!
» Advertisement
» Recent Threads
Go to first new post Ruzzykinz.
Today 06:14 PM
Last post by Bex
Today 06:54 PM
47 Replies, 67 Views
Go to first new post Anglo-Saxon Riddles
Today 05:53 PM
by Fewmitz
Last post by Wtf_Is_That?
Today 06:53 PM
3 Replies, 14 Views
Go to first new post Florida Teen Commits...
11-23-2008 05:30 AM
by Seelyon
Last post by scromlette
Today 06:52 PM
29 Replies, 315 Views
Go to first new post Fucking AMAZING!!!
11-21-2008 02:16 PM
Last post by Hodizzle
Today 06:52 PM
14 Replies, 118 Views
Go to first new post Heroes-Series
11-18-2008 01:29 PM
Last post by scromlette
Today 06:46 PM
16 Replies, 93 Views
Reply
 
LinkBack Thread Tools Display Modes

 Making a More Advanced Calculator by Zachafer.
Old 04-22-2007, 09:08 AM   #1 (permalink)
Banned

Zachafer is offline
 
Join Date: Apr 2007
Posts: 95
GPoints: 7
iTrader: 0 / 0%
Zachafer Is gaining popularity
Rep Power: 0
Making a More Advanced Calculator by Zachafer.

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.
  Reply With Quote

 
Old 04-23-2007, 01:00 AM   #2 (permalink)
Underground

Male second2none is offline
 
Join Date: Sep 2006
Location: BrisBANE <----
Age: 19
Posts: 5,025
GPoints: 356
iTrader: 1 / 100%
second2none Is a Party Captainsecond2none Is a Party Captainsecond2none Is a Party Captain
Rep Power: 16
Great post Keep it up.
__________________
This is from:
Screenies Of A Mod
Code:
How did you do it? FLP , jotform, some other form of hacking? - First Class Noob
Lawl.. funny shit.

Quote:
Originally Posted by Kore
By k[ore] on Today, 08:44 AM
i'll give you rep alright, but it won't be positive.
Lawl Ownt

Hoes forgot to eat a dick and shut the FUCK UP!
  Reply With Quote

 
Old 04-25-2007, 07:50 PM   #3 (permalink)
Banned

Zachafer is offline
 
Join Date: Apr 2007
Posts: 95
GPoints: 7
iTrader: 0 / 0%
Zachafer Is gaining popularity
Rep Power: 0
Thanks.
This tut took forever to make.

Kane,
Can you see the programming team board?
  Reply With Quote

 
Old 04-26-2007, 12:38 AM   #4 (permalink)
Underground

Male second2none is offline
 
Join Date: Sep 2006
Location: BrisBANE <----
Age: 19
Posts: 5,025
GPoints: 356
iTrader: 1 / 100%
second2none Is a Party Captainsecond2none Is a Party Captainsecond2none Is a Party Captain
Rep Power: 16
Yesh I sure can o.0
__________________
This is from:
Screenies Of A Mod
Code:
How did you do it? FLP , jotform, some other form of hacking? - First Class Noob
Lawl.. funny shit.

Quote:
Originally Posted by Kore
By k[ore] on Today, 08:44 AM
i'll give you rep alright, but it won't be positive.
Lawl Ownt

Hoes forgot to eat a dick and shut the FUCK UP!
  Reply With Quote

 
Old 04-27-2007, 06:28 PM   #5 (permalink)
Banned

Zachafer is offline
 
Join Date: Apr 2007
Posts: 95
GPoints: 7
iTrader: 0 / 0%
Zachafer Is gaining popularity
Rep Power: 0
Cool.
Did you try the tut?
  Reply With Quote

 
Old 04-27-2007, 06:31 PM   #6 (permalink)
Underground

Male second2none is offline
 
Join Date: Sep 2006
Location: BrisBANE <----
Age: 19
Posts: 5,025
GPoints: 356
iTrader: 1 / 100%
second2none Is a Party Captainsecond2none Is a Party Captainsecond2none Is a Party Captain
Rep Power: 16
nah xD I don't need to make a calculator. But If I did I know how to make one anyway This is good for people trying to learn.
__________________
This is from:
Screenies Of A Mod
Code:
How did you do it? FLP , jotform, some other form of hacking? - First Class Noob
Lawl.. funny shit.

Quote:
Originally Posted by Kore
By k[ore] on Today, 08:44 AM
i'll give you rep alright, but it won't be positive.
Lawl Ownt

Hoes forgot to eat a dick and shut the FUCK UP!
  Reply With Quote

 
Old 04-27-2007, 07:24 PM   #7 (permalink)
Banned

Zachafer is offline
 
Join Date: Apr 2007
Posts: 95
GPoints: 7
iTrader: 0 / 0%
Zachafer Is gaining popularity
Rep Power: 0
You can make lots with this.
  Reply With Quote
Reply

Bookmarks



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Powered by vBadvanced CMPS v3.0 RC2

All times are GMT -7. The time now is 06:55 PM.


vBulletin skin developed by: eXtremepixels
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The contents of this webpage are copyright © 2006-2008 GamingGutter.com. All Rights Reserved.

Page generated in 0.12755704 seconds (100.00% PHP - 0% MySQL) with 19 queries