|
分類:[VB.NET]
純2259さんに教えていただいた通りやってみましたが、やはりだめでした… どこかに少し手を加えればよいと思うのですが。 Public Class Form電卓 Inherits System.Windows.Forms.Form
Dim R1 As Integer Dim R2 As Integer Dim Op As Integer Dim CL As Integer Private Sub Button終了_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button終了.Click End End Sub
Private Sub Form電卓_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load TextR.Text = "" R1 = 0 R2 = 0 Op = 1 CL = True End Sub
Private Sub 数字キー(ByVal n As Integer) If CL Then R1 = 0 CL = False End If R1 = R1 * 10 + n TextR.Text = R1 End Sub Private Sub 演算キー(ByVal o As Integer) R2 = R1 Op = o CL = True End Sub Private Sub 計算() Select Case Op Case 1 R1 = R2 + R1 Case 2 R1 = R2 - R1 Case 3 R1 = R2 * R1 Case 4 R1 = R2 \ R1
End Select TextR.Text = R1
End Sub
Private Sub KeyN0_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN0.Click 数字キー(0) End Sub
Private Sub KeyN1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN1.Click 数字キー(1) End Sub Private Sub KeyN2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN2.Click 数字キー(2) End Sub
Private Sub KetN3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KetN3.Click 数字キー(3) End Sub
Private Sub KeyN4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN4.Click 数字キー(4) End Sub
Private Sub KeyN5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN5.Click 数字キー(5) End Sub
Private Sub KeyN6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN6.Click 数字キー(6) End Sub
Private Sub KeyN7_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN7.Click 数字キー(7) End Sub
Private Sub KeyN8_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN8.Click 数字キー(8) End Sub
Private Sub KeyN9_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyN9.Click 数字キー(9) End Sub
Private Sub KeyOA_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyOA.Click 演算キー(1) End Sub
Private Sub KeyOS_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyOS.Click 演算キー(2) End Sub
Private Sub KeyOM_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyOM.Click 演算キー(3) End Sub
Private Sub KeyOD_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyOD.Click 演算キー(4) End Sub
Private Sub KeyEQ_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyEQ.Click 計算() CL = True End Sub
Private Sub KeyCL_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles KeyCL.Click TextR.Text = "" R1 = 0 R2 = 0 Op = 1 CL = True End Sub End Class
|