247 lines
No EOL
8.5 KiB
VB.net
Executable file
247 lines
No EOL
8.5 KiB
VB.net
Executable file
Option Explicit On
|
|
Public Class frmCalculator
|
|
|
|
Dim FirstNumber As Double
|
|
Dim SecondNumber As Double
|
|
Dim AnswerNumber As Double
|
|
Dim ArithmeticProcess As String
|
|
Dim nextCalculation As Boolean
|
|
|
|
|
|
Private Sub frmCalculator_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
If frmMain.lang = "KOR" Then
|
|
Me.Text = "계산기"
|
|
mnuFile.Text = "파일"
|
|
mnuFileExit.Text = "나가기"
|
|
mnuSettings.Text = "설정"
|
|
mnuSettingsColor.Text = "색상"
|
|
mnuSettingsColorDefault.Text = "기본값"
|
|
mnuSettingsColorRed.Text = "토마토"
|
|
mnuSettingsColorYellow.Text = "노랑"
|
|
mnuSettingsColorGreen.Text = "초록"
|
|
mnuSettingsColorBlue.Text = "파랑"
|
|
mnuSettingsColorPink.Text = "분홍"
|
|
mnuSettingsColorBlack.Text = "검정"
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnOne_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOne.Click
|
|
TextBox1.Text = TextBox1.Text & 1
|
|
RichTextBox1.Text &= 1
|
|
End Sub
|
|
|
|
Private Sub btnTwo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTwo.Click
|
|
TextBox1.Text = TextBox1.Text & 2
|
|
RichTextBox1.Text &= 2
|
|
End Sub
|
|
|
|
Private Sub btnThree_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnThree.Click
|
|
TextBox1.Text = TextBox1.Text & 3
|
|
RichTextBox1.Text &= 3
|
|
End Sub
|
|
|
|
Private Sub btnFour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFour.Click
|
|
TextBox1.Text = TextBox1.Text & 4
|
|
RichTextBox1.Text &= 4
|
|
End Sub
|
|
|
|
Private Sub btnFive_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFive.Click
|
|
TextBox1.Text = TextBox1.Text & 5
|
|
RichTextBox1.Text &= 5
|
|
End Sub
|
|
|
|
Private Sub btnSix_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSix.Click
|
|
TextBox1.Text = TextBox1.Text & 6
|
|
RichTextBox1.Text &= 6
|
|
End Sub
|
|
|
|
Private Sub btnSeven_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSeven.Click
|
|
TextBox1.Text = TextBox1.Text & 7
|
|
RichTextBox1.Text &= 7
|
|
End Sub
|
|
|
|
Private Sub btnEight_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEight.Click
|
|
TextBox1.Text = TextBox1.Text & 8
|
|
RichTextBox1.Text &= 8
|
|
End Sub
|
|
|
|
Private Sub btnNine_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNine.Click
|
|
TextBox1.Text = TextBox1.Text & 9
|
|
RichTextBox1.Text &= 9
|
|
End Sub
|
|
|
|
Private Sub btnZero_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnZero.Click
|
|
TextBox1.Text = TextBox1.Text & 0
|
|
RichTextBox1.Text &= 0
|
|
End Sub
|
|
|
|
Private Sub btnPoint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPoint.Click
|
|
TextBox1.Text = TextBox1.Text & "."
|
|
RichTextBox1.Text &= "."
|
|
End Sub
|
|
|
|
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
|
|
FirstNumber = Val(TextBox1.Text)
|
|
TextBox1.Text = "0"
|
|
ArithmeticProcess = "+"
|
|
RichTextBox1.Text &= "+"
|
|
nextCalculation = True
|
|
If nextCalculation = True Then
|
|
OperationFalse()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnSubstract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSubstract.Click
|
|
FirstNumber = Val(TextBox1.Text)
|
|
TextBox1.Text = "0"
|
|
ArithmeticProcess = "-"
|
|
RichTextBox1.Text &= "-"
|
|
nextCalculation = True
|
|
If nextCalculation = True Then
|
|
OperationFalse()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnMultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMultiply.Click
|
|
FirstNumber = Val(TextBox1.Text)
|
|
TextBox1.Text = "0"
|
|
ArithmeticProcess = "x"
|
|
RichTextBox1.Text &= "x"
|
|
nextCalculation = True
|
|
If nextCalculation = True Then
|
|
OperationFalse()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub btnDivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDivide.Click
|
|
FirstNumber = Val(TextBox1.Text)
|
|
TextBox1.Text = "0"
|
|
ArithmeticProcess = "/"
|
|
RichTextBox1.Text &= "/"
|
|
nextCalculation = True
|
|
If nextCalculation = True Then
|
|
OperationFalse()
|
|
End If
|
|
End Sub
|
|
|
|
|
|
Private Sub btnResult_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnResult.Click
|
|
SecondNumber = Val(TextBox1.Text)
|
|
If ArithmeticProcess = "+" Then
|
|
AnswerNumber = FirstNumber + SecondNumber
|
|
End If
|
|
If ArithmeticProcess = "-" Then
|
|
AnswerNumber = FirstNumber - SecondNumber
|
|
End If
|
|
If ArithmeticProcess = "x" Then
|
|
AnswerNumber = FirstNumber * SecondNumber
|
|
End If
|
|
If ArithmeticProcess = "/" Then
|
|
AnswerNumber = FirstNumber / SecondNumber
|
|
End If
|
|
TextBox1.Text = AnswerNumber
|
|
RichTextBox1.Text = AnswerNumber
|
|
OperationTrue()
|
|
End Sub
|
|
Sub Focusing()
|
|
btnOne.Focus()
|
|
btnTwo.Focus()
|
|
btnThree.Focus()
|
|
btnFour.Focus()
|
|
btnFive.Focus()
|
|
btnSix.Focus()
|
|
btnSeven.Focus()
|
|
btnEight.Focus()
|
|
btnNine.Focus()
|
|
btnZero.Focus()
|
|
btnAdd.Focus()
|
|
btnSubstract.Focus()
|
|
btnMultiply.Focus()
|
|
btnDivide.Focus()
|
|
btnResult.Focus()
|
|
btnPoint.Focus()
|
|
btnClear.Focus()
|
|
End Sub
|
|
Sub Checked()
|
|
mnuSettingsColorRed.Checked = False
|
|
mnuSettingsColorYellow.Checked = False
|
|
mnuSettingsColorGreen.Checked = False
|
|
mnuSettingsColorBlue.Checked = False
|
|
mnuSettingsColorPink.Checked = False
|
|
mnuSettingsColorBlack.Checked = False
|
|
mnuSettingsColorDefault.Checked = False
|
|
End Sub
|
|
Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
|
|
RichTextBox1.Clear()
|
|
TextBox1.Clear()
|
|
OperationTrue()
|
|
End Sub
|
|
|
|
Sub OperationFalse()
|
|
btnAdd.Enabled = False
|
|
btnSubstract.Enabled = False
|
|
btnMultiply.Enabled = False
|
|
btnDivide.Enabled = False
|
|
End Sub
|
|
|
|
Sub OperationTrue()
|
|
btnAdd.Enabled = True
|
|
btnSubstract.Enabled = True
|
|
btnMultiply.Enabled = True
|
|
btnDivide.Enabled = True
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorRed_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorRed.Click
|
|
Me.BackColor = Color.Tomato
|
|
Checked()
|
|
mnuSettingsColorRed.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorYellow_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorYellow.Click
|
|
Me.BackColor = Color.Yellow
|
|
Checked()
|
|
mnuSettingsColorYellow.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorGreen_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorGreen.Click
|
|
Me.BackColor = Color.Lime
|
|
Checked()
|
|
mnuSettingsColorGreen.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorBlue_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorBlue.Click
|
|
Me.BackColor = Color.SkyBlue
|
|
Checked()
|
|
mnuSettingsColorBlue.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorPink_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorPink.Click
|
|
Me.BackColor = Color.Pink
|
|
Checked()
|
|
mnuSettingsColorPink.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorBlack_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorBlack.Click
|
|
Me.BackColor = Color.Black
|
|
Checked()
|
|
mnuSettingsColorBlack.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuSettingsColorDefault_Click(sender As Object, e As EventArgs) Handles mnuSettingsColorDefault.Click
|
|
Me.BackColor = SystemColors.Control
|
|
Checked()
|
|
mnuSettingsColorDefault.Checked = True
|
|
Focusing()
|
|
End Sub
|
|
|
|
Private Sub mnuFileExit_Click(sender As Object, e As EventArgs) Handles mnuFileExit.Click
|
|
Me.Close()
|
|
End Sub
|
|
|
|
End Class |