Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


Visual Calculator filter_list
Author
Message
Visual Calculator #1
What you need;
  • 16 Buttons
  • TextBox

Starting up;
  1. Add a "Module"

The rest;
  1. Label the 16 buttons as such;
  2. Button1 = "1"
  3. Button2 = "2"
  4. Button3 = "3"
  5. Button4 = "4"
  6. Button5 = "5"
  7. Button6 = "6"
  8. Button7 = "7"
  9. Button8 = "8"
  10. Button9 = "9"
  11. Button10 = "0"
  12. Button11 = "."
  13. Button12 = "Enter"
  14. Button13 = "+"
  15. Button14 = "-"
  16. Button15 = "*"
  17. Button16 = "/"

Add the following into Module.vb;
Code:
Module Module1

    Sub ShowValue(ByVal Butt As Button)
        Form1.TextBox1.Text = Form1.TextBox1.Text & Butt.Text
    End Sub
    Sub Arithmetic(ByVal Butt As Button)
        Form1.Value1 = Val(Form1.TextBox1.Text)
        Form1.Oper = Butt.Text
        Form1.TextBox1.Text = ""
    End Sub

    Sub Calculate()
        Select Case Form1.Oper
            Case "+"
                Form1.TextBox1.Text = Form1.Value1 + Val(Form1.TextBox1.Text)
            Case "-"
                Form1.TextBox1.Text = Form1.Value1 - Val(Form1.TextBox1.Text)
            Case "*"
                Form1.TextBox1.Text = Form1.Value1 * Val(Form1.TextBox1.Text)
            Case "/"
                Form1.TextBox1.Text = Form1.Value1 / Val(Form1.TextBox1.Text)

        End Select
    End Sub

End Module

Add the following into Form1.vb;

Code:
Public Class Form1
    Public Value1 As Double
    Public Oper As Char

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        ShowValue(Button10)
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        TextBox1.Text = TextBox1.Text & "."
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ShowValue(Button3)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ShowValue(Button2)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ShowValue(Button1)
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Calculate()
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        Arithmetic(Button13)
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        Arithmetic(Button14)
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        Arithmetic(Button16)
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        Arithmetic(Button15)
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        ShowValue(Button9)
    End Sub

    Private Sub Button8_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ShowValue(Button8)
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        ShowValue(Button7)
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ShowValue(Button4)
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        ShowValue(Button5)
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        ShowValue(Button6)
    End Sub
End Class

How it should look when finished;

Design;
[Image: 2ZPSM.png]

Reply

RE: Visual Calculator #2
Great share SUPER HQ! Again nice share Smile


Reply

RE: Visual Calculator #3
(11-11-2012, 04:32 AM)#Sync# Wrote: Great share SUPER HQ! Again nice share Smile

Thanks for the input.

I'll be making C# versions of all my VB ones as well.

Reply







Users browsing this thread: 1 Guest(s)