Автор: LostCost
Дата сообщения: 11.09.2009 21:54
Здравствуйте всем. У меня есть вобщем то самый что не на есть простой и банальный вопрос, но с учетом того что 2 недели как начал основательно заниматься бейсиком(считая мат. часть) я думаю это простительно.
Вобщем, моя задача сделать боее менее работающий многострочный калкулятор. Пока что имеется вот это:
[more=Код]Public Class Form1
Dim a, b, oper As Double
Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)
End Sub
Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)
End Sub
Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)
End Sub
Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)
If TextBox2.Text = 0 Then
TextBox3.Text = "Невозможно"
Label1.Text = "На ноль делить нельзя!"
Else : Label1.Text = ""
End If
End Sub
Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
End Sub
Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
TextBox3.Text = Math.Sin(Val(TextBox1.Text))
End Sub
Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
TextBox3.Text = Math.Cos(Val(TextBox1.Text))
End Sub
Private Sub Button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button17.Click
TextBox3.Text = Math.Sqrt(Val(TextBox1.Text))
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
TextBox3.Text = Val(TextBox1.Text) ^ 2
End Sub
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "0" Then
TextBox1.Text = "1"
Else
TextBox1.Text = TextBox1.Text + "1"
End If
If oper = "" Then
a = TextBox1.Text
Else
b = TextBox1.Text
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
End Sub
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
End Sub
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
[/more]
Сделано вроде бы все что нужно, но я не могу никак разобраться с кнопками "1", "2" и т.п. и знак равенства("="). Вот код "1":
Код: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If TextBox1.Text = "0" Then
TextBox1.Text = "1"
Else
TextBox1.Text = TextBox1.Text + "1"
End If
If oper = "" Then
a = TextBox1.Text
Else
b = TextBox1.Text
End If
End Sub