Download as pdf or txt
Download as pdf or txt
You are on page 1of 35

PROGRAM-1

Design a digital clock using timer control

Private Sub Timer1_Timer()

Dim hh As Byte, mm As Byte, ss As Byte

ss = Int(sec.Caption)

mm = Int(min.Caption)

hh = Int(hr.Caption)

ss = ss + 1

If ss = 60 Then

ss = 0

mm = mm + 1
End If

If mm = 60 Then

mm = 0

hh = hh + 1

End If

If hh = 24 Then

hh = 0

End If

sec.Caption = Format(ss, "00")

min.Caption = Format(mm, "00")

hr.Caption = Format(hh, "00")

End Sub

OUTPUT
PROGRAM-2

Design an application that accepts an item name from user and adds it to a listbox .

Private Sub cmdAdd_Click()

If txtAdd.Text <> " " Then

Listbox.AddItem txtAdd.Text

Else

MsgBox ("you must have something to add to the list box"), , "error"

End If

txtAdd.SetFocus

txtAdd.Text = " "

End Sub

Private Sub cmdExit_Click()

End

End Sub
OUTPUT
PROGRAM-3

Design an application to implement password check for security

Private Sub cmdCancil_Click()

End

End Sub

Private Sub cmdOk_Click()

If txtPassword.Text = "apgdca" Then

MsgBox ("Password ok")

Else

MsgBox ("wrong password,try again!!")

End If

End Sub
OUTPUT
PROGRAM-4

Create an application that offers various food items to select from and a mode of payment
.It then displays the total amount payable.

Private Sub cmdbill_Click()

Dim amount As Integer

If chkPizza.Value = 1 Then

amount = amount + 100

End If

If Chkdosa.Value = 1 Then

amount = amount + 40

End If

If chkchow.Value = 1 Then
amount = amount + 50

End If

If Optcash.Value = True Then

MsgBox ("your cash bill amount is" + Str(amount))

Else

If optcredit.Value = True Then

MsgBox ("your credit bill amount is" + Str(amount))

End If

End If

End Sub

Private Sub Cmdexit_Click()

End

End Sub
OUTPUT
PROGRAM-5

Loop to print factorial of a given number

Private Sub Command1_Click()

Dim num As Integer, factorial As Integer

num = InputBox("enter a number")

factorial = 1

For x = 1 To num

factorial = factorial * x

Next x

Print "the factorial of given number is"; factorial

End Sub
OUTPUT
PROGRAM-6

Write a procedure to calculate the Simple Interest and invoke this procedure in another
procedure

Private Sub cmdexit_Click()

End

End Sub

Private Sub cmdSI_Click()

Dim P As Single, R As Single, T As Single

P = InputBox("Enter principal")

R = InputBox("enter rate")

T = InputBox("Enter time")
Call SInterest(P, R, T)

End Sub

Public Sub SInterest(P As Single, R As Single, T As Single)

Dim S As Single

S = P * R * T / 100

Print "Simple Interest is" & S

End Sub

OUTPUT
PROGRAM-7

Program to change form background color


Private Sub Command1_Click()

If red.Value = True Then

Form1.BackColor = vbRed

ElseIf green.Value = True Then

Form1.BackColor = vbGreen

Else

Form1.BackColor = vbBlue

End If

End Sub

OUTPUT
PROGRAM-8

Design a form to find out total marks,average and result whether student is passed or
failed
Dim totalmarks As Integer

Dim average As Integer

Private Sub Command1_Click()

totalmarks = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)

Text4.Text = (Str(totalmarks))

End Sub

Private Sub Command2_Click()

average = totalmarks / 3

Text5.Text = (Str(average))
End Sub

Private Sub Command3_Click()

If average > 80 = True Then

MsgBox ("student is passed")

Else

MsgBox ("student is failed")

End If

End Sub

OUTPUT
PROGRAM-9

Design a form of different shapes by using timer

Private Sub Timer1_Timer()

If Shape1.Visible Then

Shape2.Visible = True

Shape1.Visible = False

Shape3.Visible = False

ElseIf Shape2.Visible Then


Shape3.Visible = True

Shape1.Visible = False

Shape2.Visible = False

Else

Shape1.Visible = True

Shape2.Visible = False

Shape3.Visible = False

End If

End Sub

OUTPUT
PROGRAM -10

Design a form to find out which one is greater

-10

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 = True Then

MsgBox ("a is greater")


ElseIf b > a And b > c = True Then

MsgBox ("b is greater")

Else

MsgBox ("c is greater")

End If

End Sub

OUTPUT
PROGRAM-11
Design a form to check even or odd

Private Sub Command1_Click()

Dim num As Integer

num = Val(Text1)

If num Mod 2 Then

Text2.Text = "odd number"

Else

Text2.Text = "even number"

End If

Form1.Cls

End Sub

OUTPUT
PROGRAM-12

Design a form for student information

Private Sub Command1_Click()

Dim roll As Integer

roll = Text1.Text

List1.Clear

Select Case roll

Case 1

List1.AddItem ("3208")
List1.AddItem ("sarita")

List1.AddItem ("mundsa")

Case 2

List1.AddItem ("3206")

List1.AddItem ("Ritu")

List1.AddItem ("Rohad")

Case 3

List1.AddItem ("3205")

List1.AddItem ("Simran")

List1.AddItem ("sisana")

Case 4

List1.AddItem ("3207")

List1.AddItem ("Bharti")

List1.AddItem ("Rohtak")

Case 5

List1.AddItem ("3203")

List1.AddItem ("Sourabh")

List1.AddItem ("sampla")

Case 6

List1.AddItem ("3209")

List1.AddItem ("Ajay")

List1.AddItem ("rohtak")

End Select

End Sub
OUTPUT
PROGRAM-13

Design a form to check divisibility


Private Sub cmdcd_Click()

Dim N1 As Integer, N2 As Integer

N1 = InputBox("enter 1st no")

N2 = InputBox("enter 2nd no")

Call Divisible(N1, N2)

End Sub

Private Sub cmdexit_Click()

End

End Sub

Public Sub Divisible(Num1 As Integer, Num2 As Integer)

If Num1 Mod Num2 = 0 Then


Print "Divisible"

Else

Print "not divisible"

End If

End Sub

OUTPUT

You might also like