Ask Experts Questions for FREE Help !
Ask
    snaveenkumar123's Avatar
    snaveenkumar123 Posts: 1, Reputation: 1
    New Member
     
    #1

    Jan 12, 2007, 05:23 AM
    How to create a calculator in VB 6.0
    Hi! I'm Naveen
    I have a school project.
    Its 2 create a calculator in VB 6.0 using just basic or easy methods.
    Help me with the coding.
    Also I just need a simple coding , not a complex one or my teacher won't accept.
    Help!!
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #2

    Jan 12, 2007, 07:03 AM
    First may I call your attention to these guidelines on asking for homework help

    https://www.askmehelpdesk.com/langua...elp-board.html

    If you have a specific problem ask. Show us the code you have written and what doesn't work about it. We can then help.
    bloomer152000's Avatar
    bloomer152000 Posts: 2, Reputation: 1
    New Member
     
    #3

    Jul 2, 2007, 03:38 PM
    How to create a calculator in VB 6.0 ?
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #4

    Jul 2, 2007, 04:52 PM
    Please read the previous reply.
    corporateattitude's Avatar
    corporateattitude Posts: 1, Reputation: 1
    New Member
     
    #5

    Aug 30, 2007, 01:21 AM
    Quote Originally Posted by snaveenkumar123
    Hi! im Naveen
    i hav a school project.
    its 2 create a calculator in VB 6.0 using just basic or easy methods.
    help me with the coding.
    also i just need a simple coding , not a complex one or my teacher wont accept.
    Help!!!!
    you can so this:

    text1.text = int(text2.text) + int(text3.text)

    hope this help.
    Criza's Avatar
    Criza Posts: 2, Reputation: 1
    New Member
     
    #6

    Nov 26, 2007, 12:21 AM
    Crizhenrizh14
    Hi! I'm cRiza
    I have a project on how to create an calculator using the visual basic, can you tell me what is the code.. please . Thank you!
    ScottGem's Avatar
    ScottGem Posts: 64,966, Reputation: 6056
    Computer Expert and Renaissance Man
     
    #7

    Nov 26, 2007, 09:27 AM
    Quote Originally Posted by Criza
    i hav a project on how to create an calculator using the visual basic, can you tell me what is the code..? please . thank you!
    Did you bother reading the replies before posting?
    Duane in Japan's Avatar
    Duane in Japan Posts: 282, Reputation: 8
    Full Member
     
    #8

    Nov 29, 2007, 08:45 PM
    Instead of using int (integer) I have started to use val (value) as it automatically creates memory for complex numbers in case a decimal or other extended math is used.

    I know that in the old days, conserving memory was important and many programmers still code that way and YES it is still important but when speed is not an issue in small programs, In my opinion, val is a good cover all, just in case.

    Look through these sites for your homework needs, you still have to do the research, don't forget to take a Research class when you get to college.

    Visual Basic Explorer - VB Forums - Message Board - ezboard.com
    The Code Project - Free Source Code and Tutorials

    Don't copy, do your own work, tailor it to something simple when you locate a good sample.
    fsn0daka's Avatar
    fsn0daka Posts: 2, Reputation: 1
    New Member
     
    #9

    Dec 29, 2010, 12:45 PM
    Option Explicit
    Dim first As String
    Dim second As String
    Dim operation As String
    Dim output As Double

    Private Sub Command1_Click(Index As Integer)
    Text1.Text = Text1.Text + Command1(Index).Caption
    End Sub
    Private Sub Command10_Click()
    If Len(Text1.Text) Then
    Text1.Text = Command10 * Text1.Text
    End If
    End Sub

    Private Sub Command11_Click()
    Text1.Text = " "
    operation = " "
    End Sub
    Private Sub Command12_Click()
    If Len(Text1.Text) Then
    Text1.Text = Left$(Text1.Text, Len(Text1.Text) - 1)
    End If
    End Sub

    Private Sub Command2_Click()
    If InStr(Text1.Text, ".") = 0 Then
    Text1.Text = Text1.Text & "."
    End If
    End Sub
    Private Sub Command3_Click()
    Dim yn As Integer
    yn = MsgBox("Are you sure you want to exit?", vbYesNo + vbQuestion, "Exit")
    If yn = vbYes Then
    Unload Me
    End If
    End Sub

    Private Sub Command4_Click()
    first = Text1.Text
    operation = "+"
    Text1.Text = " "
    End Sub

    Private Sub Command6_Click()
    If Len(Text1.Text) Then
    second = Text1.Text
    Select Case operation
    Case "+"
    output = CDbl(first) + CDbl(second)
    Text1.Text = output
    Case "-"
    output = CDbl(first) - CDbl(second)
    Text1.Text = output
    Case "*"
    output = CDbl(first) * CDbl(second)
    Text1.Text = output
    Case "/"
    If second = 0 Then
    Text1.Text = "ERROR"
    MsgBox "Cannot be Divided by Zero!", vbCritical, "Error"
    If vbOK Then
    Text1.Text = " "
    operation = " "
    End If
    Else
    Text1.Text = first / second
    End If
    End Select
    End If
    End Sub

    Private Sub Command7_Click()
    first = Text1.Text
    operation = "-"
    Text1.Text = " "
    End Sub

    Private Sub Command8_Click()
    first = Text1.Text
    operation = "*"
    Text1.Text = " "
    End Sub

    Private Sub Command9_Click()
    first = Text1.Text
    operation = "/"
    Text1.Text = " "
    End Sub

    Private Sub Timer1_Timer()
    If Label3.Left > -Label3.Width Then
    Label3.Move Label3.Left - 100
    Else
    Label3.Left = Form1.Width
    End If
    End Sub


    TRY THIS ONE!!
    fsn0daka's Avatar
    fsn0daka Posts: 2, Reputation: 1
    New Member
     
    #10

    Dec 29, 2010, 12:47 PM
    Thanks 4 help! :))
    fazlulbcse's Avatar
    fazlulbcse Posts: 1, Reputation: 1
    New Member
     
    #11

    Oct 23, 2011, 02:52 AM
    MAKE A PROJECT OF CALCULATOR IN
    VISUAL BASIC
    First we select the Standard exe item in the view
    project dialog box,
    opening Visual
    Basic itself.
    Then we select the Textbox from the Toolbox and make
    a textbox on the form.
    Then we select the command button from the tool box
    from the tool box we make buttons 0, 1, 2, 3, 4 … 9, +,
    =,-,*, /, clear.
    After these all buttons are made. Then we need the
    buttons to be coded. Thus double click on the button
    numbered “1”, following coding is done:
    Private sub Command 1-Click ()
    Text1.Text = Text 1. Text + “1”
    End Sub
    Double clicking on the Button “2”
    Private sub Command 2-Click ()
    Text1.Text = Text 1. Text + “2”
    End Sub
    Double clicking on the Button “3”
    Private sub Command 3-Click ()
    Text1.Text = Text 1. Text + “3”
    End Sub
    Double clicking on the Button “4”
    Private sub Command 4-Click ()
    Text1.Text = Text 1. Text + “4”
    End Sub
    Double clicking on the Button “5”
    Private sub Command 5-Click ()

    Text1.Text = Text 1. Text + “5”
    End Sub
    Double clicking on the Button “6”
    Private sub Command 6-Click ()
    Text1.Text = Text 1. Text + “6”
    End Sub
    Double clicking on the Button “7”
    Private sub Command 7-Click ()
    Text1.Text = Text 1. Text + “7”
    End Sub
    Double clicking on the Button “8”
    Private sub Command 8-Click ()
    Text1.Text = Text 1. Text + “8”
    End Sub
    Double clicking on the Button “9”
    Private sub Command 9-Click ()
    Text1.Text = Text 1. Text + “9”
    End Sub
    Double clicking on the Button “0”
    Private sub Command 10-Click ()
    Text1.Text = Text 1. Text + “0”
    End Sub
    Double clicking on the Button “.”
    Private sub Command 11-Click ()
    Text1.Text = Text 1. Text + “.”
    End Sub
    Double clicking on the Button “+”
    Private sub Command 12-Click ()
    a= Text 1. Text
    Text1.Text = ”+”
    d=1
    End Sub
    Double clicking on the Button “-”
    Private sub Command 13-Click ()
    a= Text 1. Text
    Text1.Text =”-”
    d=3
    End Sub
    Double clicking on the Button “*”
    Private sub Command 14-Click ()
    a= Text 1. Text
    Text1.Text =”*”
    d=3
    End Sub
    Double clicking on the Button “/”
    Private sub Command 15-Click ()
    a= Text 1. Text
    Text1.Text =”/”
    d=4
    End Sub
    Double clicking on the Button “Square”
    Private sub Command 16-Click ()
    a= Text 1. Text
    Text1.Text =”*”
    C=a*a
    Text1.Text = c
    End Sub
    Double clicking on the Button “Factorial”
    Private sub Command 17-Click ()
    a= Text 1. Text
    Text1.Text =”i”
    e= 1
    for I = s to step-1
    e = e*i
    Text1.Text = e
    End Sub
    Double clicking on the Button “Clear”
    Private sub Command 18-Click ()
    Text1.Text ( )
    End Sub
    Double clicking on the Button “=”
    Private sub Command 19-Click ()
    b = Text1.Text
    Select case d%
    Case 1: c= a + b
    Text1.Text = c
    Case 2: c = a - b
    Text1.Text=c
    Case 3: c= a * b
    Text1.Text = c
    Case 4: c= a / b
    Text1.Text = c
    End Select
    End Sub
    Following figure shows how a
    calculator made in Visual Basic
    Looks :



    Rizannylle's Avatar
    Rizannylle Posts: 1, Reputation: 1
    New Member
     
    #12

    Dec 8, 2011, 06:32 PM
    Code for Number button from 0-9:

    Private Sub command1_Click()
    Text1.Text = Text1.Text & "1"
    End Sub

    Private Sub Command10_Click()
    Text1.Text = Text1.Text & "0"
    End Sub

    Private Sub Command2_Click()
    Text1.Text = Text1.Text & "2"
    End Sub

    Private Sub Command3_Click()
    Text1.Text = Text1.Text & "3"
    End Sub

    Private Sub Command4_Click()
    Text1.Text = Text1.Text & "4"
    End Sub

    Private Sub Command5_Click()
    Text1.Text = Text1.Text & "5"
    End Sub

    Private Sub Command6_Click()
    Text1.Text = Text1.Text & "6"
    End Sub

    Private Sub Command7_Click()
    Text1.Text = Text1.Text & "7"
    End Sub

    Private Sub Command8_Click()
    Text1.Text = Text1.Text & "8"
    End Sub

    Private Sub Command9_Click()
    Text1.Text = Text1.Text & "9"
    End Sub

    Code For addition,subtraction.division and Multiplication:

    Private Sub Command13_Click()
    Label1.Caption = Val(Text1.Text) * Val(Text2.Text)
    End Sub

    Private Sub Command14_Click()
    Label1.Caption = Val(Text1.Text) / Val(Text2.Text)
    End Sub

    Private Sub Command11_Click()
    Label1.Caption = Val(Text1.Text) + Val(Text2.Text)
    End Sub

    Private Sub Command12_Click()
    Label1.Caption = Val(Text1.Text) - Val(Text2.Text)
    End Sub

    Exit code for Clear:

    Private Sub Command16_Click()
    Label1.Caption = ""
    Text1.Text = ""
    Text2.Text = ""
    End Sub

    Exit Code:

    Private Sub Command17_Click()
    Unload Me
    End Sub

    ANN...

Not your question? Ask your question View similar questions

 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.


Check out some similar questions!

Assembler Calculator [ 1 Answers ]

I am doing an assembler class and I am supposed to create a program that simulates a calculator using plus, minus and multiply operands no divide. If anyone could help me with this code it would be greatly appreciated. Thanks.

How do I create a bootable cd? [ 7 Answers ]

My friend has had problems reloading windows xp after formating, missing files and such. I have tried some other solutions and come to the conclusion he had a bad disk. Now somewhere or somehow he got a hold of the files or an XP disk , I'm really not sure, but he asked if I knew how to make a...

How to do e-0.05 on a calculator [ 5 Answers ]

Hi there, What are the exact steps I press on a calculator to do the following: - 40e-0.05 I keep getting the wrong answer? Any help is appreciated

How can create chocolate? [ 1 Answers ]

Hi: Would you mind tell me how can make chocolate?


View more questions Search