Textboxes are used for user to input the 1st and 2nd number, the 3rd box is the answer textbox.
Input 2 numbers and check the arithmetic radio button. The answer will be shown in the 3rd textbox.
I built the calculator form but I am having trouble assigning values into the arithmetic function.
here's my code:
#Region " Windows Form Designer generated code " Public Sub New() MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() 'Add any initialization after the InitializeComponent() call End Sub 'Form overrides dispose to clean up the component list. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Required by the Windows Form Designer Private components As System.ComponentModel.IContainer 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox Friend WithEvents TextBox2 As System.Windows.Forms.TextBox Friend WithEvents TextBox3 As System.Windows.Forms.TextBox Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() Me.TextBox1 = New System.Windows.Forms.TextBox Me.TextBox2 = New System.Windows.Forms.TextBox Me.TextBox3 = New System.Windows.Forms.TextBox Me.RadioButton1 = New System.Windows.Forms.RadioButton Me.RadioButton2 = New System.Windows.Forms.RadioButton Me.RadioButton3 = New System.Windows.Forms.RadioButton Me.RadioButton4 = New System.Windows.Forms.RadioButton Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.SuspendLayout() ' 'TextBox1 ' Me.TextBox1.Location = New System.Drawing.Point(152, 40) Me.TextBox1.Name = "TextBox1" Me.TextBox1.Size = New System.Drawing.Size(75, 20) Me.TextBox1.TabIndex = 0 Me.TextBox1.Text = "" ' 'TextBox2 ' Me.TextBox2.Location = New System.Drawing.Point(152, 88) Me.TextBox2.Name = "TextBox2" Me.TextBox2.Size = New System.Drawing.Size(75, 20) Me.TextBox2.TabIndex = 1 Me.TextBox2.Text = "" ' 'TextBox3 ' Me.TextBox3.Location = New System.Drawing.Point(152, 136) Me.TextBox3.Name = "TextBox3" Me.TextBox3.Size = New System.Drawing.Size(75, 20) Me.TextBox3.TabIndex = 2 Me.TextBox3.Text = "" ' 'RadioButton1 ' Me.RadioButton1.Location = New System.Drawing.Point(24, 40) Me.RadioButton1.Name = "RadioButton1" Me.RadioButton1.Size = New System.Drawing.Size(75, 23) Me.RadioButton1.TabIndex = 3 Me.RadioButton1.Text = "+" ' 'RadioButton2 ' Me.RadioButton2.Location = New System.Drawing.Point(24, 120) Me.RadioButton2.Name = "RadioButton2" Me.RadioButton2.Size = New System.Drawing.Size(75, 23) Me.RadioButton2.TabIndex = 4 Me.RadioButton2.Text = "*" ' 'RadioButton3 ' Me.RadioButton3.Location = New System.Drawing.Point(24, 88) Me.RadioButton3.Name = "RadioButton3" Me.RadioButton3.Size = New System.Drawing.Size(75, 23) Me.RadioButton3.TabIndex = 5 Me.RadioButton3.Text = "-" ' 'RadioButton4 ' Me.RadioButton4.Location = New System.Drawing.Point(24, 168) Me.RadioButton4.Name = "RadioButton4" Me.RadioButton4.Size = New System.Drawing.Size(75, 23) Me.RadioButton4.TabIndex = 6 Me.RadioButton4.Text = "/" ' 'Button1 ' Me.Button1.Location = New System.Drawing.Point(120, 184) Me.Button1.Name = "Button1" Me.Button1.TabIndex = 7 Me.Button1.Text = "Calculate" ' 'Button2 ' Me.Button2.Location = New System.Drawing.Point(208, 184) Me.Button2.Name = "Button2" Me.Button2.TabIndex = 8 Me.Button2.Text = "Clear" ' 'Form1 ' Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13) Me.ClientSize = New System.Drawing.Size(292, 266) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.RadioButton4) Me.Controls.Add(Me.RadioButton3) Me.Controls.Add(Me.RadioButton2) Me.Controls.Add(Me.RadioButton1) Me.Controls.Add(Me.TextBox3) Me.Controls.Add(Me.TextBox2) Me.Controls.Add(Me.TextBox1) Me.Name = "Form1" Me.Text = "Calculator" Me.ResumeLayout(False) End Sub #End Region Private Sub RadioButton1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged [b] Return x + y[/b] 'error' End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged Dim x As Double End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged Dim y As Double End Sub Private Sub TextBox3_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox3.TextChanged End Sub Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click End Sub Private Sub RadioButton3_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged End Sub End Class
Also, how do I get the Calculate and clear button to work?
Help is appreciated.

New Topic/Question
Reply




MultiQuote



|