계산기 쭈~욱 만드는데 모르겠어염...답변좀 해주세욤^^
Case "+": Text1 = operand + CDbl(Text1)
Case "-": Text1 = operand - CDbl(Text1)
Case "*": Text1 = operand * CDbl(Text1)
Case "/": Text1 = operand / CDbl(Text1)
Case "\": Text1 = operand \ CDbl(Text1)
Case "mod": Text1 = operand Mod CDbl(Text1)
요런식으로 짜고 싶은뎅..
답변 부탁드립니당^^
전체 소스는
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00C0E0FF&
Caption = "Form1"
ClientHeight = 6210
ClientLeft = 60
ClientTop = 345
ClientWidth = 5655
LinkTopic = "Form1"
ScaleHeight = 6210
ScaleWidth = 5655
StartUpPosition = 3 'Windows 기본값
Begin VB.CommandButton Command1
BackColor = &H00C0C0C0&
Caption = "="
Height = 735
Index = 18
Left = 3840
TabIndex = 20
Top = 4920
Width = 735
End
Begin VB.CommandButton Command1
Caption = "sqr"
Height = 735
Index = 17
Left = 2880
TabIndex = 19
Top = 4920
Width = 735
End
Begin VB.CommandButton Command1
Caption = "mod"
Height = 735
Index = 16
Left = 1920
TabIndex = 18
Top = 4920
Width = 735
End
Begin VB.CommandButton Command1
Caption = "\"
Height = 735
Index = 15
Left = 960
TabIndex = 17
Top = 4920
Width = 735
End
Begin VB.CommandButton Command1
Caption = "-"
Height = 735
Index = 10
Left = 3840
TabIndex = 16
Top = 3960
Width = 735
End
Begin VB.CommandButton Command1
Caption = "+"
Height = 735
Index = 14
Left = 2880
TabIndex = 15
Top = 3960
Width = 735
End
Begin VB.CommandButton Command1
Caption = "."
Height = 735
Index = 13
Left = 1920
TabIndex = 14
Top = 3960
Width = 735
End
Begin VB.CommandButton Command1
Caption = "9"
Height = 735
Index = 9
Left = 960
TabIndex = 13
Top = 3960
Width = 735
End
Begin VB.CommandButton Command1
Caption = "/"
Height = 735
Index = 11
Left = 3840
TabIndex = 12
Top = 3000
Width = 735
End
Begin VB.CommandButton Command1
Caption = "8"
Height = 735
Index = 8
Left = 2880
TabIndex = 11
Top = 3000
Width = 735
End
Begin VB.CommandButton Command1
Caption = "7"
Height = 735
Index = 7
Left = 1920
TabIndex = 10
Top = 3000
Width = 735
End
Begin VB.CommandButton Command1
Caption = "6"
Height = 735
Index = 6
Left = 960
TabIndex = 9
Top = 3000
Width = 735
End
Begin VB.CommandButton Command1
Caption = "*"
Height = 735
Index = 12
Left = 3840
TabIndex = 8
Top = 2040
Width = 735
End
Begin VB.CommandButton Command1
Caption = "5"
Height = 735
Index = 5
Left = 2880
TabIndex = 7
Top = 2040
Width = 735
End
Begin VB.CommandButton Command1
Caption = "4"
Height = 735
Index = 4
Left = 1920
TabIndex = 6
Top = 2040
Width = 735
End
Begin VB.CommandButton Command1
Caption = "3"
Height = 735
Index = 3
Left = 960
TabIndex = 5
Top = 2040
Width = 735
End
Begin VB.CommandButton Command1
Caption = "clear"
Height = 735
Index = 32
Left = 3840
TabIndex = 4
Top = 1080
Width = 735
End
Begin VB.CommandButton Command1
Caption = "2"
Height = 735
Index = 2
Left = 2880
TabIndex = 3
Top = 1080
Width = 735
End
Begin VB.CommandButton Command1
Caption = "1"
Height = 735
Index = 1
Left = 1920
TabIndex = 2
Top = 1080
Width = 735
End
Begin VB.CommandButton Command1
Caption = "0"
Height = 735
Index = 0
Left = 960
TabIndex = 1
Top = 1080
Width = 735
End
Begin VB.TextBox Text1
Alignment = 1 '오른쪽 맞춤
Height = 495
Left = 960
TabIndex = 0
Top = 360
Width = 3615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private operand As Integer
Private operator As String
Private Sub Command1_Click(index As Integer)
Select Case Command1(index).Caption
Case "clear": Text1 = ""
Case "+", "-", "*", "/", "\", "mod", "sqr"
operand = CDbl(Text1)
operator = Command1(index).Caption
Text1 = ""
Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "."
Text1 = Text1 + Command1(index).Caption
Case "="
Select Case operator
Case "+": Text1 = operand + CDbl(Text1)
Case "-": Text1 = operand - CDbl(Text1)
Case "*": Text1 = operand * CDbl(Text1)
Case "/": Text1 = operand / CDbl(Text1)
Case "\": Text1 = operand \ CDbl(Text1)
Case "mod": Text1 = operand Mod CDbl(Text1)
End Select
End Select
End Sub
카페 게시글
질문/답변
계산기에서 루트(제곱근. sqr)는 어떤 식으로 짜야 하나욤??
다음검색