QuestionCalculator?

Posts 115 of 15 · Page 1 of 1
Calculator?
Does anyone know how to make a sorta basic calculator. ive googled it but all the tuts are sorta complicated.

it needs = + - * and / anyone know?
Calculators are probably the most simplistic code you can make, it makes for a great "Hello World" App.

The reason for this is because by nature programming languages work best with Logic and mathematical equations. I don't have the code here, but I know that sourcecodester has a calculator application you can download (Credit to elemir)

If you want his tut open source app for learning, it can be found there.
thanks, i add your sig to my sig
Textbox3.Text = Val(Textbox1.Text) + Val(Textbox2.text)
Textbox3.Text = Val(Textbox1.Text) - Val(Textbox2.text)
Textbox3.Text = Val(Textbox1.Text) * Val(Textbox2.text)
Textbox3.Text = Val(Textbox1.Text) / Val(Textbox2.text)
Textbox3.Text = Val(Textbox1.Text) ^ Val(Textbox2.text)

You could also use a numericupdown..
That is a way to calculate using multiple text boxes, typically you would want to limit it to a single textbox which handles the result and the equations
i know how to make a good one but i cant remember it off my head ill have to post it l8ter if you still want it
If I am correct I think he downloaded the one from Sourcecodester, Which means he has the whole code and sample application, however , as always, a TUT can only benefit the VB section, So maybe you can create a tut for everyone
i didnt downloaded it, i changed my mind. but i think a tut would be quite helpful
prolly with a variable and hotkeys?

Like...

dim x as integer

now if hotkey + is pressed then...

x + value

elseif hotkey - is pressed

x - value

if hotkey enter is pressed

richtextbox1.text = x
x = 0

Something like that =D
Code:
Public Class Form5

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim Number1 As Integer
        Number1 = TextBox1.Text
        Dim Number2 As Integer
        Number2 = TextBox2.Text

        If CheckBox1.Checked = True Then
            TextBox3.Text = (Number1 + Number2)
        End If
        If CheckBox2.Checked = True Then
            TextBox3.Text = (Number1 - Number2)
        End If
        If CheckBox3.Checked = True Then
            TextBox3.Text = (Number1 / Number2)
        End If
        If CheckBox4.Checked = True Then
            TextBox3.Text = (Number1 * Number2)
        End If
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False
        CheckBox4.Checked = False
    End Sub

    Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyToolStripMenuItem.Click
        Clipboard.SetDataObject(TextBox3.Text)

    End Sub

    Private Sub ClearToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ClearToolStripMenuItem.Click
        TextBox1.Text = ""
        TextBox2.Text = ""
        TextBox3.Text = ""
        CheckBox1.Checked = False
        CheckBox2.Checked = False
        CheckBox3.Checked = False
        CheckBox4.Checked = False
    End Sub

    Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PasteToolStripMenuItem.Click
        TextBox3.Text = Clipboard.GetDataObject().GetData(DataFormats.Text)
    End Sub
End Class


Hur dur, from a year ago.
what number does button 5 go to?
the "=" button...isn't this obvious, lol..
Posts 115 of 15 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?