You are on page 1of 67

ASSIGNMENT -1

AIM:-Design an application that finds area of circle.

PROGRAM:-
Const Pi=3.14159

Private Sub cmdarea_Click()

Dim radius As Single

Dim area As Double

radius= Val(Text1.Text)

area = Pi* radius * radius

MsgBox ("area of circle is " & Str(area))

End Sub

Private Sub cmdexit_Click()

End

End Sub
S.No. Control Properties Value
1. Label 1 Caption Enter the radius

2. Text 1 Text [empty]

3. Command1 (Name) cmdarea


Caption Find area of
Circle
4. Command2 (Name) cmdexit
Caption EXIT
ASSIGNMENT -2
AIM:-Design an application to perform arithmetic operations

PROGRAM:-
Private Sub cmdsum_Click()

Dim num1 as single

Dim num2 as single

Dim sum as single

Num1= val(text1.text)

Num2= val(text2.text)

Sum = num1+num2

Msgbox (“sum of numbers is” & str(sum))

End sub

Private Sub cmddiv_Click()

Dim num1 as single

Dim num2 as single

Dim divison as single

Num1= val(text1.text)

Num2= val(text2.text)

divison = num1/num2

Msgbox (“divison of numbers is” & str(sum))

End sub

Private Sub cmdmul_Click()


Dim num1 as single

Dim num2 as single

Dim multi as single

num1= val(text1.text)

num2= val(text2.text)

multi = num1*num2

Msgbox (“multiplication of numbers is” & str(sum))

End sub

Private Sub cmdsub_Click()

Dim num1 as single

Dim num2 as single

Dim difference as single

num1= val(text1.text)

num2= val(text2.text)

difference = num1-num2

Msgbox (“sum of numbers is” & str(sum))

End sub

Private Sub cmdexit_Click()

End

End sub
S.No. Control Properties Value

1. Form 1 Caption Arithmetic


Operators

2. Label 1 (Name) Caption Lbl1


Enter Number 1
3. Label 2 (Name) Caption Ibl2
Enter Number 2
4. Text 1 Text [Empty]

5. Text 2 Text [Empty]

6. Command 1 (Name) cmdadd


Caption ADD
7. Command 2 (Name) cmdsub

Caption SUBTRACT
8. Command 3 (Name) cmdmul

Caption MULTIPLY
9. Command 4 (Name) cmddiv
Caption DIVIDE
ASSIGNMENT -3
AIM: -Design an application that find largest of three numbers

PROGRAM: -
Private Sub cmdlar_Click()

Dim n1 As Single

Dim n2 As Single

Dim n3 As Single

Dim largest As Single

n1= Val(Text1.Text)

n2= Val(Text2.Text)

n3= Val(Text3.Text)

If n1> n2 And n1> n3 Then

largest = n1

Elself n2>n1 And n2> n3 Then

largest = n2

Elselargest = n3

End If

MsgBox ("Largest number is " & largest)

End Sub

Private Sub cmdexit_Click ()

End

End Sub
S.No. Control Properties Value

1. Form 1 Caption Largest number

2. Label 1 (Name) Lblnum1


Caption Enter number 1

3. Label 2 (Name) Lblnum2


Caption Enter number 2

4. Label 3 (Name) Lblnum3


Caption Enter number 3

5. Text 1 Text [Empty]

6. Text 2 Text [Empty]

7. Text 3 Text [Empty]

8. Command 1 (Name) cmdlar


Caption Find largest

9. Command 2 (Name) cmdexit


Caption Exit
ASSIGNMENT -4
AIM:-Design an application to check whether a given number is odd or
even.

PROGRAM:-
Private Sub cmdcheck_Click()

Dim n As Integer

n = Val(Text1.Text)

If n Mod 2 = 0 Then

MsgBox ("Even")

Else

MsgBox ("odd")

End If

End Sub

Private Sub cmdexit_Click()

End

End Sub
S.No. Control Properties Value

1. Form 1 Caption Even_odd

2. Label 1 (Name) Lblnum


Caption Enter Number

3. Text 1 Text [Empty]

4. Command 1 (Name) cmdcheck


Caption Even _odd

5. Command 2 (Name) cmdexit


Caption Exit
ASSIGNMENT -5
AIM:-Design an application to calculate HRA on basis of basic pay of
employee according to following criteria:

BASIC PAY HRA

<=2000 200

>2000 and <=4000 350

>4000 500

PROGRAM:-
Private Sub cmdhra_Click ()

Dim Basic As Integer Dim HRA As Integer

Basic = Val (Text1.Text) If Basic <= 2000 Then

HRA = 200

ElseIf Basic <= 4000 Then

HRA = 350

HRA = 500

Else

End If

MsgBox ("hra is" & HRA)

End Sub

Private Sub cmdexit_Click ()

End

End Sub
S.No Control Properties Value

1. Label 1 Caption Enter basic pay

2. Text 1 Text Empty

3. Command 1 Name cmdhra


Caption Find HRA

4. Command 2 Name cmdexit


Caption Exit
ASSIGNMENT -6
AIM:-Design an application to find palindrome of a number using
while loop.

PROGRAM:-
Private Sub Command1_Click ()

Dim num As Integer

Dim digit As Integer

Dim temp As Integer

Dim rnum As Integer

rnum = 0

num = Text1.Text

temp = num

Do

digit = temp Mod 10

temp = temp \ 10

rnum = rnum * 10 + digit

Loop While (temp > 0)

If rnum = num Then

MsgBox ("the number is a palindrome")

Else

MsgBox ("the number is not a palindrome")

End If

End Sub
Private Sub Command2_Click ()

End

End Sub
S.No. Control Properties Value

1. Form 1 Caption Palindrome

2. Label 1 (Name) Lblnum


Caption Enter a number

3. Text 1 Text [Empty]

4. Command 1 (Name) Command1


Caption Palindrome?

5. Command 2 (Name) Command2


Caption Exit
ASSIGNMENT -7
AIM:- Design an application to print table of a number on form using
do-while loop.

PROGRAM:-
Private Sub Command1_Click()

List1.Clear

Dim n As Integer

n=0

Do While n < 10

n=n+1

r = Val(Text1.Text) * n

List1.AddItem (Text1.Text & "x" & n & "=" & r)

Loop

Text1.SetFocus

End Sub
S.No. Control Properties Value

1. Form 1 Caption Table

2. List 1 List [Empty]

3. Text 1 Text [Empty]

4. Command 1 (Name) Command1


Caption Calculate
ASSIGNMENT -8
AIM:- Design an application to sum of series upto n terms using for
loop. Series is X+x*3/3!+x*5/5!+----

PROGRAM:-
Private Sub cmdsum_Click()

Dim x As Single

Dim terms As Double

Dim sum As Double

Dim n, i As Integer

Dim fact As Single

fact = 1

x= Val(Text1.Text)

n= Val(Text2.Text)

term=x Sum x

For i = 1 To n

term=term*x*x

fact-fact (2i+1)* (2 * i)

sum = sum + term / fact

Next I MsgBox ("Sum of the series" & sum)

End Sub

Private Sub cmdexit_Click ()

End

End Sub
S.No. Control Properties Value

1. Form1 Caption Sum of series

2. Label 1 (Name) Label1


Caption Enter the value of x

3. Label 2 (Name) Label2


Caption Enter the number of
series

4. Text 1 Text [Empty]

5. Text 2 Text [Empty]

6. Command 1 (Name) cmdsum


Caption Sum of the series

7. Command 2 (Name) cmdexit


Caption Exit
ASSIGNMENT -9
AIM:- Design an application to calculate Income Tax according to
following criteria:

INCOME TAX

up to 1,0000 0

1,00,001 to 2,50,000 10%

2,50,001 to 5,00,000 20%

above 5,00,000 30%

PROGRAM:-
Private Sub Command1_Click()

Dim income As Single

Dim tax As Single

income = Val(Text1.Text)

If (income < 100000) Then

tax = 0

ElseIf (income > 100001 And income < 250000) Then

tax = (income - 100000) * 0.1

ElseIf (income > 250000 And income < 500000) Then

tax = (income - 250000) * 0.2 + 15000

Else

tax = (income - 500000) * 0.3 + 50000 + 15000

End If
MsgBox ("tax is" & tax)

End Sub

Private Sub Command2_Click ()

End

End Sub
S.No. Control Properties Value

1. Label 1 (Name) Label 1


Caption Enter income tax

2. Text 1 Text [Empty]

3. Command 1 (Name) Command 1


Caption Calculate tax

4. Command 2 (Name) Command 2


Caption Exit
ASSIGNMENT -10
AIM:-Design an application to find mean of n number using for loop.

PROGRAM:-
Dim n As Integer

Dim num (1 To 20) As Double

Dim mean As Double

Dim sum As Double

Dim i As Integer

Private Sub cmdmean_Click()

n = Val (InputBox (" enter total numbers "))

Print

Print " total numbers are " & n

Print

sum = 0

For i = 1 To n

num(i) = Val (InputBox (" enter number " & i))

sum = sum + num(i)

Print " number " & i & " is " & num(i)

Next

mean = sum / n

Print

Print " average is " & mean


End Sub

Private Sub cmdexit_Click ()

End

End Sub
S.No. Control Property Value

1. Form 1 Caption Form 1

2. Command 1 (Name) cmdmean


Caption Find Mean

3. Command 2 (Name) cmdexit


Caption EXIT
ASSIGNMENT -11
AIM:-Calculate shipment cost for an order which may either be placed
by a wholesaler or a retailers according to the following criteria

FOR UNIT PRICE FOR PRICE FOR


WHOLESALERS (PER RETAILERS(PER UNIT)
UNIT)
1-10 RS.100/- RS.120/-
11-20 RS.90/- RS.110/-
21-25 RS.80/- RS.100/-
26-30 RS.70/- RS.90/-
31-35 RS.60/- RS.80/-
51 and above RS.50/- RS.70/-

PROGRAM:-
Private Sub Command1_Click ()

Dim x As Single

x = Val (Text1.Text)

Dim price As Single

Select Case x

Case 1 To 10

price = x * 120

Case 11 To 20

price = x * 110

Case 21 To 25

price = x * 100
Case 26 To 30

price = x * 90

Case 31 To 50

price = x * 80

Case Else

price = x * 70

End Select

MsgBox ("price for retailer is=" & price)

End Sub

Private Sub Command2_Click ()

Dim x As Single

x = Val (Text1.Text)

Dim price As Single

Select Case x

Case 1 To 10

price = x * 100

Case 11 To 20

price = x * 90

Case 21 To 25

price = x * 80

Case 26 To 30

price = x * 70
Case 31 To 50

price = x * 60

Case Else

price = x * 50

End Select

MsgBox ("price for retailer is=" & price)

End Sub

Private Sub Command3_Click ()

End

End Sub
S.No. Control Properties Value

1. Label 1 (Name) Label 1


Caption Enter units
2. Text 1 Text [Empty]

3. Command 1 (Name) Command 1


Caption wholesaler
4. Command 2 (Name) Command 2
Caption Retailer
5. Command 3 (Name) Command 3
Caption Exit
ASSIGNMENT -12
AIM:- Design an application for bubble sort using one – dimensional
array.

PROGRAM:-
Dim n As Integer

Dim num (1 To 20) As Double

Dim i As Integer, j As Integer, temp As Integer

Private Sub cmdbsort_Click ()

n = Val(InputBox(" Enter Total Numbers "))

Print

Print " Total Numbers are " & n

Print

For i = 1 To n

num (i) = Val(InputBox ("Enter Number" & i))

Print “Number” & i & “is” & num (i)

Next

For i = 1 To n

For j = 1 To n-1

If num(j) >num (j + 1) Then

temp = num (j)

num (j + 1) = temp

End If

Next
Next

Print

Print “The Sorted Array is "

Print

For i = 1 To n

Print num(i);

Next

End Sub

Private Sub cmdexit_Click ()

End

End Sub
S.No Control Property Value

1. Form 1 Caption Form 1

2. Command 1 Name cmdbsort


Caption Bubble Sort

3. Command 2 Name cmdexit


Caption Exit
ASSIGNMENT -13
AIM:- Design an application for sum of 2 matrices using two-
dimensional array.

PROGRAM:-
Dim a (1 To 5, 1 To 5) As Integer.

Dim b (1 To 5, 1 To 5) As Integer

Dim s (1 To 5, 1 To 5) As Integer

Dim i As Integer, j As Integer

Dim m As Integer, n As Integer

Private Sub cmdmsum_Click ()

m = Val (Input Box ("Enter Total rows "))

n = Val (InputBox("Enter Total Columns "))

Print "Order of Matrices is "& m &“ “& n

Print

Print “The elements of 1st matrix are "

For i= 1 To m

For j= 1 To n

a (i, j) = Val (InputBox(" Enter Element Row#" & i & "Column#” & j))

Print a (i, j);

Next

Print

Next
Print

Print “The elements of 2nd matrix are "

For i= 1 To m

For j= 1 To n

b (i, j) = Val (Input Box (" Enter Element Row#" & i & "Column#" & j ))

Print b (i, j);

Next Print

Next

For i = 1 To m

For j = 1 To n

s (i, j) = a (i, j) + b (i, j)

Next Next

Print

Print " The Sum of two matrices are "

For i = 1 To m

For j= 1 To n

Print s (i, j);

Next Print

Next

End Sub

Private Sub cmdexit_Click ()

End
End Sub

S.No. Control Properties Value

1. Form 1 Caption Form 1

2. Command 1 (Name) cmdmsum


Caption Matrices Sum
3. Command 2 (Name) cmdexit
caption EXIT
ASSIGNMENT -14
AIM:- Design a calculator using control array in visual basic.

PROGRAM:-

Dim op1 As Double

Dim op2 As Double

Dim operator As String

Dim result As Double

Private Sub Command1_Click(Index As Integer)

Text1.Text = Text1.Text & Command1(Index).Caption

op1 = Val(Text1.Text)

End Sub

Private Sub Command3_Click(Index As Integer)

Text1.Text = " "

op2 = op1

op1 = 0

operator = Command3(Index).Caption

End Sub
Private Sub Command4_Click()

Select Case operator

Case "+"

result = op2 + op1

Text1.Text = result

Case "-"

result = op2 - op1

Text1.Text = result

Case "*"

result = op2 * op1

Text1.Text = result

Case "/"

result = op2 / op1

Text1.Text = result

End Select

op1 = result

End Sub

Private Sub Command5_Click()

Text1.Text = Val(Sqr(op1))
End Sub

Private Sub Command6_Click()

op2 = 0

op1 = 0

Text1.Text = " "

End Sub

Private Sub Command7_Click()

op1 = 0

Text1.Text = " "

End Sub
S.No. Control Properties Value

1. Form 1 Caption Calculator

2. Text 1 Text [Empty]

3. Command 1 (Name) Command1


Caption
4. Command 2 (Name) Command2
Caption
5. Command 3 (Name) Command3
Caption
6. Command 4 (Name) Command4
Caption
7. Command 5 (Name) Command5
Caption Index 0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10

8. Command 6 (Name) Command6


Caption Index + 0
- 1
* 2
/ 3
ASSIGNMENT-15
AIM:- Design an application for notepad with the help of login form.

Program:
Private Sub cmdok_Click()

If txtpswd.Text = "shivank" Then

MsgBox ("Password,OK")

Else

MsgBox ("Invalid Password, Try Again")

End If

End Sub

Private Sub cmdcancel_Click()

End

End Sub
S.No. Control Properties Value

1. Label 1 (Name) Lblnum


Caption USERNAME

2. Label 2 (Name) Lblpswd


caption PASSWORD

3. Text 1 (Name) Txtname


Text [empty]

4. Text 2 Name Txtpswd


Text [empty]
Password char

5. Command 1 (Name) cmdok


Caption OK

6. Command 2 (Name) cmdcancel


caption CANCEL

7. Form 1 caption Login form


Private Sub Command1_Click()

Clipboard.SetText Text1.SelText

Command2.Enabled = True

End Sub

Private Sub Command2_Click()

Clipboard.SetText Text1.SelText

Text1.SelText = ""

Command1.Enabled = True

End Sub

Private Sub Command3_Click()

Text1.SelText = Clipboard.GetText

End Sub

Private Sub Command4_Click()

Text1.SelStart = 0

Text1.SelLength = Len(Text1.Text)

Text1.SetFocus

End Sub

Private Sub Command5_Click()

End

End Sub
S.No. Control Property Value

1. Form 1 Caption Notepad

2. Text 1 Name Text1


Text Empty
Multiline True
scrollbar 2-vertical

3. Command 1 Name Command 1


Caption cut

4. Command 2 Name Command 2


Caption copy

5. Command 3 Name Command 3


Caption paste
Enabled False

6. Command 4 Name Command 4


Caption select all
7. Command 5 Name Command 5
caption exit

You might also like