0% found this document useful (0 votes)
248 views83 pages

Visual Basics Asgnmnt 1

The document describes the code for various math and logic operations that can be performed in a Visual Basic application. It includes code snippets to add, subtract, multiply and divide numbers. Additional operations covered include finding greater than/less than/equal comparisons, even/odd determinations, leap year calculations, compound interest, simple interest and unit conversions. Code is also provided to generate number patterns and sequences, like the Fibonacci series. The formatting and layout of the various calculator and logic functions are specified through commands and form design.

Uploaded by

Riya Jain
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
248 views83 pages

Visual Basics Asgnmnt 1

The document describes the code for various math and logic operations that can be performed in a Visual Basic application. It includes code snippets to add, subtract, multiply and divide numbers. Additional operations covered include finding greater than/less than/equal comparisons, even/odd determinations, leap year calculations, compound interest, simple interest and unit conversions. Code is also provided to generate number patterns and sequences, like the Fibonacci series. The formatting and layout of the various calculator and logic functions are specified through commands and form design.

Uploaded by

Riya Jain
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 83

Addition & Subtraction Of 2 Numbers

FORMAT
COMMANDS
FINAL LAYOUT OF FORM

Addition
Subtraction
CALCULATOR
Format
COMMANDS

1) Addition

Private Sub Command1_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r = a + b
Text3.Text = r
End Sub
2 ) SUBTRACTION

Private Sub Command2_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r = a - b
Text3.Text = r
End Sub
3)MULTIPLY

Private Sub Command3_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r=a*b
Text3.Text = r
End Sub
4) DIVISION

Private Sub Command4_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r=a/b
Text3.Text = r
End Sub
5) MOD

Private Sub Command5_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
r = a Mod b
Text3.Text = r
End Sub
6) CLEAR

Private Sub Command6_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

7) EXIT

Private Sub Command7_Click()


End
End Sub
FINAL LAYOUT OF FORM

1) ADDITION
2) SUBTRACTION
3) MULTIPLY
4) DIVIDE
5) MOD
GREATER THAN / LESSER THAN / EQUAL

FORMAT
COMMANDS

1)GREATER THAN

Private Sub Command1_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If (a >= b) Then
MsgBox "first number is greater"
Else
MsgBox "second number is greater"
End If
End Sub
2) LESSER THAN

Private Sub Command2_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If (a <= b) Then
MsgBox "first number is lesser"
Else
MsgBox "second number is lesser"
End If
End Sub
3) EQUAL TO

Private Sub Command3_Click()


Dim a As Integer
Dim b As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
If (a = b) Then
MsgBox "both the numbers are equal"
Else
MsgBox "both the numbers are not equal"
End If
End Sub
4) CLEAR

Private Sub Command4_Click()


Text1.Text = ""
Text2.Text = ""
End Sub

5) EXIT

Private Sub Command5_Click()


End
End Sub
FINAL LAYOUT OF FORM

1) GREATER THAN
2) LESSER THAN
3) EQUAL TO
EVEN OR ODD NUMBER
COMMAND

EVEN/ODD NUMBER

Private Sub Command1_Click()


n = Val(Text1.Text)
If (n Mod 2 = 0) Then
MsgBox "number is even"
Else
MsgBox "number is odd"
End If
End Sub
CLEAR

Private Sub Command2_Click()


Text1.Text = ""
End Sub

EXIT

Private Sub Command3_Click()


End
End Sub
FINAL LAYOUT OF FORM

EVEN NUMBER
ODD NUMBER
LEAP YEAR
COMMAND

LEAP YEAR

Private Sub Command1_Click()


n = Val(Text1.Text)
If (n Mod 400 = 0) Then
MsgBox " leap year"
ElseIf (n Mod 100 = 0) Then
MsgBox " not a leap year"
ElseIf (n Mod 4 = 0) Then
MsgBox " leap year"
Else
MsgBox " not a leap year"
End If
End Sub
CLEAR

Private Sub Command2_Click()


Text1.Text = ""
End Sub

EXIT

Private Sub Command3_Click()


End
End Sub
FINAL LAYOUT OF THE FORM

*A LEAP YEAR
* NOT A LEAP YEAR
COMPARISON OF 3 NUMBERS
COMMANDS

GREATER
Private Sub Command1_Click()
Dim a As Integer
Dim b As Integer
Dim c As Integer
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
If (a >= b) And (a >= c) Then
MsgBox "first number is greater"
ElseIf (b >= c) And (b >= a) Then
MsgBox "second number is greater"
Else
MsgBox "third number is greater"
End If
End Sub
CLEAR
Private Sub Command3_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

EXIT
Private Sub Command4_Click()
End
End Sub
FINAL LAYOUT OF FORM
FORMATION OF “ ABCDE”

FORM LAYOUT
COMMANDS

*SERIAL WISE
Private Sub Command1_Click()
For i = 65 To 69 Step 1
For j = 65 To i Step 1
Print Chr(j);
Next j
Print
Next i
End Sub
* REVERSE ORDER
Private Sub Command2_Click()
For i = 69 To 65 Step -1
For j = 65 To i Step 1
Print Chr(j);
Next j
Print
Next i
End Sub
*COMBINING BOTH
Private Sub Command3_Click()
For i = 65 To 69 Step 1
For j = 65 To i Step 1
Print Chr(j);
Next j
Print
Next i
For i = 68 To 65 Step -1
For j = 65 To i Step 1
Print Chr(j);
Next j
Print
Next i
End Sub
FINAL LAYOUT OF FORM

SERAIL WISE
* REVERSE ORDER

* COMBINE
FACTORIAL OF A NUMBER

FORM LAYOUT
COMMANDS

1)FACTORIAL OF A NUMBER

Private Sub Command1_Click()


a = Val(Text1.Text)
b = 1
For i = 1 To (a - 1)
b = b * a
a = a - 1
Next i
Print b
End Sub
2) CLEAR

Private Sub Command2_Click()


Text1.Text = ""
End Sub

3) EXIT

Private Sub Command3_Click()


End
End Sub
FINAL LAYOUT OF FORM
COMPOUND INTEREST & SIMPLE INTEREST

NORMAL LAYOUT OF FORM


COMMANDS
1) COMPOUND INTEREST

Private Sub Compoundinterest(ByVal x As Single, ByVal y As


Single, ByVal z As Single)
Dim a As Single
Dim b As Single
Dim c As Single
a = x
b = y
c = z
d = a * (1 + b / 100) ^ c
MsgBox d
End Sub

Private Sub Command1_Click()


Dim ci As Single
p = Text1.Text
q = Text2.Text
r = Text3.Text
Call Compoundinterest(p, q, r)

End Sub
2) SIMPLE INTEREST

Private Sub SIMPLEinterest(ByVal x As Single, ByVal y As Single,


ByVal z As Single)
Dim a As Single
Dim b As Single
Dim c As Single
a = x
b = y
c = z
d = (a * b * c) / 100
MsgBox d
End Sub

Private Sub Command2_Click()


Dim ci As Single
p = Text1.Text
q = Text2.Text
r = Text3.Text
Call Simpleinterest(p, q, r)
End Sub
3) CLEAR

Private Sub Command3_Click()


Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

4) EXIT

Private Sub Command4_Click()


End
End Sub
FINAL LAYOUT OF FORM

1) COMPOUND INTEREST
2) SIMPLE INTEREST
CONVERSIONS
FORM LAYOUT

COMMANDS
1) Fahrenheit to Celsius
Private Sub Command1_Click()
Dim F As Integer
F = Val(Text1.Text)
c = 5 / 9 * (F - 32)
MsgBox c
End Sub

2) Celsius to Fahrenheit
Private Sub Command2_Click()
Dim c As Integer
c = Val(Text1.Text)
F = 9 / 5 * c + 32
MsgBox F
End Sub

FINAL LAYOUT OF FORM


1)Fahrenheit to Celsius

2) Celsius to Fahrenheit
USER VALUE / USER CHOICE / TABLES OF 1 AND 2
AND SERIES OF NUMBERS
FORM LAYOUT

COMMANDS
1) USER COMMANDS

Private Sub Command1_Click()


Form1.Cls
Dim a As Integer
a = Val(Text1.Text)
For i = 1 To a Step 1
Print i
Next i
End Sub

2) TABLE OF 1
Private Sub Command2_Click()
Dim i As Integer
For i = 1 To 10 Step 1
Print i
Next i
End Sub

3)TABLE OF 2
Private Sub Command3_Click()
Dim i As Integer
For i = 2 To 20 Step 2
Print i
Next i
End Sub

4) TABLE OF 1 REVERSE
Private Sub Command4_Click()
Dim i As Integer
For i = 10 To 1 Step -1
Print i
Next i
End Sub
5) TABLE OF USER VALUE

Private Sub Command5_Click()


Form1.Cls
Dim a As Integer
a = Val(Text1.Text)
For i = a To (a * 10) Step a
Print i
Next i
End Sub

6) SERIES OF A NUMBER
Private Sub Command6_Click()
j = Val(Text1.Text)
a = 0
b = 1
Print a
Print b
For i = 0 To j
c = a + b
Print c
a = b
b = c
Next
End Sub

FINAL LAYOUT OF FORM


1) USER VALUE
2) TABLE OF 1

3) TABLE OF 2
4) TABLE OF 1 REVERSE
5) TABLE OF USER VALUE
6) SERIES OF NUMBERS
FORMATION OF STARS
FORMAT LAYOUT
COMMANDS

1) SERIAL WISE

Private Sub Command1_Click()


For i = 1 To 5 Step 1
For j = 1 To i Step 1
Print "*";
Next j
Print
Next i
End Sub
2)REVERSE ORDER

Private Sub Command2_Click()


For i = 5 To 1 Step -1
For j = 1 To i Step 1
Print "*";
Next j
Print
Next i
End Sub

3) COMBINED
Private Sub Command3_Click()
For i = 1 To 5 Step 1
For j = 1 To i Step 1
Print "*";
Next j
Print
Next i
For i = 5 To 1 Step -1
For j = 1 To i Step 1
Print "*";
Next j
Print
Next i
End Sub

FINAL LAYOUT
1) SERIAL WISE

3) REVERSE
3) COMBINE
VISUAL BASIC
PRACTICAL FILE

Ideal Institute Of
Management & Technology

Name-Surabhi Rastogi
Course-BBA Gen 3rd sem
Enrollment No. -01021001709

You might also like