You are on page 1of 5

1(a).

Simple Calculator

FORM DESIGN

Dim a, op As Integer
Private Sub Command1_Click(Index As Integer)
Text1.Text = Text1.Text & Command1(Index).Caption
End Sub
Private Sub Command2_Click()
op = 1
a = CInt(Text1.Text)
Text1.Text = ""
End Sub

Private Sub Command3_Click()


op = 2
a = CInt(Text1.Text)
Text1.Text = ""
End Sub

Private Sub Command4_Click()


op = 3
a = CInt(Text1.Text)
Text1.Text = ""
End Sub

Private Sub Command5_Click()


op = 4
a = CInt(Text1.Text)
Text1.Text = ""
End Sub

Private Sub Command6_Click()


Select Case op
Case 1:
Text1.Text = a + CInt(Text1.Text)
Case 2:
Text1.Text = a - CInt(Text1.Text)
Case 3:
Text1.Text = a * CInt(Text1.Text)
Case 4:
Text1.Text = a / CInt(Text1.Text)
End Select
End Sub

Private Sub Command7_Click()


Text1.Text = Sin(CInt(Text1.Text))
End Sub

Private Sub Command8_Click()


Text1.Text = Cos(CInt(Text1.Text))
End Sub

Private Sub Command9_Click()


Text1.Text = Tan(CInt(Text1.Text))
End Sub
2a) COMMON DIALOG BOX

FORM DESIGN
CODING:

Private Sub mnexit_Click()


End
End Sub

Private Sub mnnew_Click()


text1.Text = ""
End Sub

Private Sub mnopen_Click()


Dim filelen As Integer
Dim str As String
commondialog1.showopen
Open commondialog1.FileName For Input As #3
filelen = LOF(3)
text1.Text = Input(filen, #3)
End Sub

Private Sub mnsave_Click()


commondialog1.showsave
Open commondialog1.FileName For Output As #5
Print #5, text1.Text
Close #5
End Sub
OUTPUT:

You might also like