3 Replies - 888 Views - Last Post: 02 October 2019 - 07:00 PM Rate Topic: -----

#1 jarus89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 19

why i am not being able to more number in a time? for example (1+2+3+4

Posted 02 October 2019 - 06:19 PM

Public Class Form1
    Dim Firstnum As Decimal
    Dim Secondnum As Decimal
    Dim Operations As Integer
    Dim operator_selector As Boolean = False
    Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "5"
        Else
            TextBox1.Text = "5"
        End If
    End Sub

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

    Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "1"
        Else
            TextBox1.Text = "1"
        End If

    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "2"
        Else
            TextBox1.Text = "2"
        End If
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "3"
        Else
            TextBox1.Text = "3"
        End If
    End Sub

    Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "4"
        Else
            TextBox1.Text = "4"
        End If
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "6"
        Else
            TextBox1.Text = "6"
        End If
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "7"
        Else
            TextBox1.Text = "7"
        End If
    End Sub

    Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "8"
        Else
            TextBox1.Text = "8"
        End If
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "9"
        Else
            TextBox1.Text = "9"
        End If
    End Sub

    Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
        If TextBox1.Text <> "0" Then
            TextBox1.Text += "0"
        End If
    End Sub

    Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
        TextBox1.Text = "0"
    End Sub

    Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
        TextBox1.Text = ""
    End Sub

    Private Sub Button19_Click(sender As Object, e As EventArgs) Handles Button19.Click
        If Not (TextBox1.Text.Contains(".")) Then
            TextBox1.Text += "."
        End If
    End Sub

    Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
        Firstnum = TextBox1.Text
        TextBox1.Text = ""
        operator_selector = True
        Operations = 1 '=+


    End Sub

    Private Sub Button16_Click(sender As Object, e As EventArgs) Handles Button16.Click
        Firstnum = TextBox1.Text
        TextBox1.Text = ""
        operator_selector = True
        Operations = 2 '--
    End Sub

    Private Sub Button17_Click(sender As Object, e As EventArgs) Handles Button17.Click
        Firstnum = TextBox1.Text
        TextBox1.Text = ""
        operator_selector = True
        Operations = 3 '=+
    End Sub

    Private Sub Button18_Click(sender As Object, e As EventArgs) Handles Button18.Click
        Firstnum = TextBox1.Text
        TextBox1.Text = ""
        operator_selector = True
        Operations = 4 '/
    End Sub

    Private Sub Button20_Click(sender As Object, e As EventArgs) Handles Button20.Click
        If operator_selector = True Then
            Secondnum = TextBox1.Text
            If Operations = 1 Then
                TextBox1.Text = Firstnum + Secondnum

            ElseIf Operations = 2 Then
                TextBox1.Text = Firstnum - Secondnum
            ElseIf Operations = 3 Then
                TextBox1.Text = Firstnum * Secondnum
            Else
                If Secondnum = 0 Then
                    TextBox1.Text = "Error"
                Else
                    TextBox1.Text = Firstnum /
                        Secondnum

                End If
            End If

            operator_selector = False
            End If

    End Sub

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

    End Sub
End Class

This post has been edited by astonecipher: 02 October 2019 - 06:46 PM
Reason for edit:: Code Tags


Is This A Good Question/Topic? 0
  • +

Replies To: why i am not being able to more number in a time? for example (1+2+3+4

#2 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2997
  • View blog
  • Posts: 11,541
  • Joined: 03-December 12

Re: why i am not being able to more number in a time? for example (1+2+3+4

Posted 02 October 2019 - 06:47 PM

Quote

Why I Am Not Being Able To More Number In A Time? For Example (1+2+3+4


This isn't a complete sentence, not able to what?
Was This Post Helpful? 0
  • +
  • -

#3 jarus89   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 02-October 19

Re: why i am not being able to more number in a time? for example (1+2+3+4

Posted 02 October 2019 - 06:51 PM

Sorry i didn't noticed that. Not being able to add 2 or more number at once. for example 1+2+3+4... im getting result(sum of last 2 number 3 and 4 only). If i add 2 numbers only then it show true result.
Was This Post Helpful? 0
  • +
  • -

#4 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2997
  • View blog
  • Posts: 11,541
  • Joined: 03-December 12

Re: why i am not being able to more number in a time? for example (1+2+3+4

Posted 02 October 2019 - 07:00 PM

First, change the names of the controls so they are meaningful and you know exactly what they are.

You need to keep a running total until the [C]lear button is pressed, regardless of what the label displays
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1