Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Implement the calculator logic
 

Implement the calculator logic

http://msdn.microsoft.com/en-us/library/9ew6tzdt(VS.80).aspx

I am new to visual studio creating windows projects. I have been completing the walkthrough on creating a calculator (link listed above) using windows forms designer but once the form for the calculator is complete there is a section for NEXT STEPS to implement the calculator logic. I can't find this anywhere, can anyone point me to how to complete the logic for this??
dposton  Friday, July 24, 2009 9:41 PM
Is it the buttons that you want some help with?

Can you post some simple exampel like the addition button perhaps?

Public Class Form1
    Private Number1 As Decimal
    Private Number2 As Decimal
    Private FirstNumber As Boolean = True

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        If IsNumeric(txtInput.Text) Then
            If FirstNumber Then
                Number1 = txtInput.Text
                txtInput.Text = ""
                FirstNumber = False
                txtInput.Focus()
            Else
                Number2 = txtInput.Text
                txtInput.Text = ""
                FirstNumber = True
                btnResult.Focus()
            End If
        End If
    End Sub

    Private Sub btnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResult.Click
        txtResult.Text = Number1 + Number2
    End Sub
End Class

Kenneth
Kenneth Haugland  Sunday, July 26, 2009 8:50 PM
Is it the buttons that you want some help with?

Can you post some simple exampel like the addition button perhaps?

Public Class Form1
    Private Number1 As Decimal
    Private Number2 As Decimal
    Private FirstNumber As Boolean = True

    Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        If IsNumeric(txtInput.Text) Then
            If FirstNumber Then
                Number1 = txtInput.Text
                txtInput.Text = ""
                FirstNumber = False
                txtInput.Focus()
            Else
                Number2 = txtInput.Text
                txtInput.Text = ""
                FirstNumber = True
                btnResult.Focus()
            End If
        End If
    End Sub

    Private Sub btnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResult.Click
        txtResult.Text = Number1 + Number2
    End Sub
End Class

Kenneth
Kenneth Haugland  Sunday, July 26, 2009 8:50 PM

Check out this LINK.
Only performance counts!
Sylva  Monday, July 27, 2009 8:22 PM

You can use google to search for other answers

Custom Search

More Threads

• Display X Y coordinates of moving controls
• How can i get the serial number of Hard disk or mainboard
• How do collection items notify a change to control.
• MonthCalendar cannot be modified in the designer
• How to change the properties of a control at run time
• Create a Select Resource Dialog Box
• [C# 2.0 winform] Custom Control and Automatic Serialization property on Settings
• Click once deployment - application data files path
• Highlighting text in rich text box without an IBeam
• Events for ComboBox thats inside a dataGridView