ช่วยดู code ที่ผม ทำน่อยว่ามันผิด ตรงไหน asp.net
งง มาก ครับ
พอดีฝึกทำ หาข้อมูลจากในgoogle มาเสริม เติมแต่ง กด run ได้ แต่ + - * / พอกด = อ้าวไม่ได้
ขอบคุณมา ณ โอกาศนี้ด้วยครับ
Public Class _Default Inherits System.Web.UI.Page Dim Operand1 As Double Dim Operand2 As Double Dim [Operator] As String
Private Sub cal0_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cal0.Click
IDLABLE.Text += "0"
End Sub Protected Sub cal1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal1.Click
IDLABLE.Text += "1"
End Sub
Protected Sub cal2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal2.Click
IDLABLE.Text += "2"
End Sub
Private Sub caldec_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles caldec.Click
IDLABLE.Text += "." Dim i As Integer, CountDot As Integer
For i = 1 To Len(Trim$(IDLABLE.Text)) If Mid$(Trim$(IDLABLE.Text), i, 1) = "." Then CountDot = CountDot + 1 Next If CountDot = 2 Then IDLABLE.Text = Mid$(Trim$(IDLABLE.Text), 1, Len(Trim$(IDLABLE.Text)) - 1)
End Sub
Protected Sub cal3_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal3.Click
IDLABLE.Text += "3" End Sub
Protected Sub cal4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal4.Click
IDLABLE.Text += "4" End Sub
Protected Sub cal5_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal5.Click
IDLABLE.Text += "5" End Sub
Protected Sub cal6_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal6.Click
IDLABLE.Text += "6" End Sub
Protected Sub cal7_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal7.Click
IDLABLE.Text += "7" End Sub
Protected Sub cal8_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal8.Click
IDLABLE.Text += "8" End Sub
Protected Sub cal9_Click(ByVal sender As Object, ByVal e As EventArgs) Handles cal9.Click
IDLABLE.Text += "9" End Sub
Protected Sub calc_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calc.Click IDLABLE.Text = "" Operand1 = 0 Operand2 = 0
End Sub
Protected Sub calRst_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calRst.Click
Select Case [Operator]
Case "+" IDLABLE.Text = Operand1 + Operand2
Case "-" IDLABLE.Text = Operand1 - Operand2
Case "*" IDLABLE.Text = Operand1 * Operand2
Case "/" If Operand2 = 0 Then Exit Sub IDLABLE.Text = Operand1 / Operand2
End Select
Operand2 = Val(IDLABLE.Text)
End Sub
Protected Sub calplus_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calplus.Click IDLABLE.Text = "" Operand1 = Operand2 Operand2 = 0 [Operator] = "+" End Sub
Protected Sub calminus_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calminus.Click Operand1 = Operand2 IDLABLE.Text = "" [Operator] = "-" End Sub
Protected Sub calmul_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calmul.Click Operand1 = Operand2 IDLABLE.Text = "" [Operator] = "*" End Sub
Protected Sub caldiv_Click(ByVal sender As Object, ByVal e As EventArgs) Handles caldiv.Click Operand1 = Operand2 IDLABLE.Text = "" [Operator] = "/" End Sub
Protected Sub calNegative_Click(ByVal sender As Object, ByVal e As EventArgs) Handles calNegative.Click Operand2 = -Operand2 IDLABLE.Text = Operand2 End Sub
End Class
|