Вы находитесь на странице: 1из 9

University of Engineering and Technology Lahore Civil Engineering Department

CODDING OF CALCULATOR IN VISUAL BASIC


STRUCTUAL ENGINEERING LAB

Submited To: Dr Aun Bashir

Submited By: Afzal Waseem 2007-Civil-87


Section B

University of Engineering and Technology Lahore Civil Engineering Department

University of Engineering and Technology Lahore Civil Engineering Department

Private Sub Command1_Click() Text1.Text = Text1.Text + "1" End Sub Private Sub Command10_Click() Text1.Text = Text1.Text + "0" End Sub Private Sub Command11_Click() If Not IsNumeric(Text1.Text) Then MsgBox "Please enter numbers.", vbInformation 'you may also consider erasing it Text1.Text = "" End If a = Val(Text1.Text) Text1.Text = "" End Sub Private Sub Command12_Click() If Not IsNumeric(Text1.Text) Then MsgBox "Please enter numbers.", vbInformation 'you may also consider erasing it Text1.Text = "" End If a = Val(Text1.Text) Text1.Text = "" End Sub Private Sub Command13_Click() If Not IsNumeric(Text1.Text) Then MsgBox "Please enter numbers.", vbInformation 'you may also consider erasing it Text1.Text = "" End If a = Val(Text1.Text) Text1.Text = "" End Sub Private Sub Command14_Click() If Not IsNumeric(Text1.Text) Then MsgBox "Please enter numbers.", vbInformation 'you may also consider erasing it Text1.Text = "" End If a = Val(Text1.Text)

University of Engineering and Technology Lahore Civil Engineering Department Text1.Text = "" End Sub Private Sub Command15_Click() If Command11.Value = True Then b = Val(Text1.Text) c=a+b Text3.Text = c Else If Command12.Value = True Then b = Val(Text1.Text) c=a-b Text1.Text = c Else If Command13.Value = True Then b = Val(Text1.Text) c=a*b Text1.Text = c Else If Command14.Value = True Then b = Val(Text1.Text) c=a/b Text1.Text = c End If End If End If End If End Sub Private Sub Command16_Click() Text1.Text = "" End Sub Private Sub Command2_Click() Text1.Text = Text1.Text + "2" End Sub Private Sub Command3_Click() Text1.Text = Text1.Text + "3" End Sub Private Sub Command4_Click() Text1.Text = Text1.Text + "4" End Sub Private Sub Command5_Click()

University of Engineering and Technology Lahore Civil Engineering Department Text1.Text = Text1.Text + "5" End Sub Private Sub Command6_Click() Text1.Text = Text1.Text + "6" End Sub Private Sub Command7_Click() Text1.Text = Text1.Text + "7" End Sub Private Sub Command8_Click() Text1.Text = Text1.Text + "8" End Sub Private Sub Command9_Click() Text1.Text = Text1.Text + "9" End Sub Private Sub Form_Load() Dim a As Single Dim b As Single Dim c As Single End Sub

University of Engineering and Technology Lahore Civil Engineering Department

University of Engineering and Technology Lahore Civil Engineering Department Private Sub Command1_Click() a = Val(Text1.Text) b = Val(Text2.Text) c=a+b Text3.Text = c If Not IsNumeric(Text1.Text) Then MsgBox "Please enter number in x.", vbInformation 'you may also consider erasing it Text1.Text = "" End If If Not IsNumeric(Text2.Text) Then MsgBox "Please enter number in y.", vbInformation 'you may also consider erasing it Text2.Text = "" End If End Sub Private Sub Command2_Click() a = Val(Text1.Text) b = Val(Text2.Text) c=a-b Text3.Text = c If Not IsNumeric(Text1.Text) Then MsgBox "Please enter number in x", vbInformation 'you may also consider erasing it Text1.Text = "" End If If Not IsNumeric(Text2.Text) Then MsgBox "Please enter number in y", vbInformation 'you may also consider erasing it Text2.Text = "" End If End Sub Private Sub Command3_Click() a = Val(Text1.Text) b = Val(Text2.Text) c=a*b Text3.Text = c If Not IsNumeric(Text1.Text) Then MsgBox "Please enter number in x", vbInformation

University of Engineering and Technology Lahore Civil Engineering Department 'you may also consider erasing it Text1.Text = "" End If If Not IsNumeric(Text2.Text) Then MsgBox "Please enter numbers only.", vbInformation 'you may also consider erasing it Text2.Text = "" End If End Sub Private Sub Command4_Click() If Not IsNumeric(Text1.Text) Then MsgBox "Please enter numbers only.", vbInformation 'you may also consider erasing it Text1.Text = "" End If If Not IsNumeric(Text2.Text) Then MsgBox "Please enter numbers only.", vbInformation 'you may also consider erasing it Text2.Text = "" GoTo 10 End If a = Val(Text1.Text) b = Val(Text2.Text) c=a/b Text3.Text = c 10 ' End Sub Private Sub Command5_Click() a = Val(Text1.Text) b = Val(Text4.Text) c = Val(Text5.Text) If Not IsNumeric(Text1.Text) Then MsgBox "Please enter the number in X to find power of.", vbInformation 'you may also consider erasing it Text1.Text = "" GoTo 10 End If d = a ^ (b / c) Text3.Text = d

University of Engineering and Technology Lahore Civil Engineering Department 10 ' End Sub Private Sub Command6_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub Private Sub Command7_Click() a = Val(Text1.Text) b = Val(Text4.Text) b = Cos(a) Text3.Text = b End Sub

Вам также может понравиться