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

P age |1

Assignment for Programming in Visual


Basic

B.Sc. (General) PART-III Examination – 2019

Name: S M Masadul Alam


Reg No.: 314-1125-1625-15
CU Roll No.:
P age |2

INDEX
Sl No. Program Page No.

01 Create a project using On Error Resume Next Statement, get a number


and divide that number by zero so that an error message should be
displayed (Division by Zero is Undefined)

02 Create a project for a company which accept Emp No., Emp name,
Salary by text boxes, sex should be selected either M or F, the
allowances HRA will be 20% of salary and DA will be 10% of salary and
these should be calculated automatically and displayed in the
respective boxes. When OK button is pressed a confirmation message
should be displayed. Make a heading also.

03 Create a project to display Fibonacci series.

04 Create a project to calculate Centigrade to Fahrenheit and vice versa.

05 Create a project to find the sum of numbers from 1 to selected value.

06 Create a project to find the simple interest.

07 Create a project to make a calculator.

08 Create a project to convert a text from uppercase to lowercase and


vice versa.

09 Create a project to make a gradation (like A, B, C, D and E) based on


total marks providing the marks of different subjects.
P age |3

Project No: 01
Create a project using On Error Resume Next Statement, get a number and divide that
number by zero so that an error message should be displayed (Division by Zero is
Undefined)

Object View:

Program Code:
Private Sub Command1_Click()

Dim a, b, c As Double

a = Text1.Text

b = Text2.Text

On Error GoTo cmnt

c=a/b

Label5.Caption = FormatNumber(c, 2)

done:

Exit Sub
P age |4

cmnt:

MsgBox "Division by Zero is Undefined"

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Label5.Caption = ""

End Sub

Private Sub Command3_Click()

Unload Me

End Sub

Form:
P age |5

Outputs:
i)

ii)
P age |6

Project No: 02
Create a project for a company which accept Emp No., Emp name, Salary by text boxes,
sex should be selected either M or F, the allowances HRA will be 20% of salary and DA
will be 10% of salary and these should be calculated automatically and displayed in the
respective boxes. When OK button is pressed a confirmation message should be
displayed. Make a heading also.

Object View:

Program Code:
Private Sub Command1_Click()

Dim no, name, sal, hra, da As Double

no = Text1.Text

name = Text2.Text

sal = Text3.Text

hra = sal * 20 / 100

da = sal * 10 / 100
P age |7

Text5.Text = hra

Text6.Text = da

MsgBox "Emp No: " & no & "; Name: " & name & vbCrLf & "Salary: " & sal & "; Sex: " &
Text4.Text & vbCrLf & "HRA: " & hra & vbCrLf & "DA: " & da

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

Option1.Value = False

Option2.Value = False

End Sub

Private Sub Option1_Click()

Text4.Text = "Female"

End Sub

Private Sub Option2_Click()

Text4.Text = "Male"

End Sub

Private Sub Command3_Click()


P age |8

End

End Sub

Form:

Outputs:
i)
P age |9

ii)
P a g e | 10

Project No: 03
Create a project to display Fibonacci series.

Object View:

Program Code:
Private Sub Command1_Click()

Dim A, B, C, N As Integer

N = Val(Text1.Text)

A=0

B=1

If N <= 0 Then

MsgBox ("You entered an invalid number of term")

ElseIf N = 1 Then

Label4.Caption = A

Else

Label4.Caption = A & " " & B & " "


P a g e | 11

For I = 2 To N - 1

C=A+B

Label4.Caption = Label4.Caption & C & " "

A=B

B=C

Next I

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Label4.Caption = ""

End Sub

Private Sub Command3_Click()

End

End Sub

Form:
P a g e | 12

Output:
i)

ii)

iii)
P a g e | 13

Project No: 04

Create a project to calculate Centigrade to Fahrenheit and vice versa.

Object View:

Program Code:
Private Sub Command1_Click()

Dim cen, far As Double

x = Val(Text1.Text)

If Option1.Value = True Then

far = 9 / 5 * x + 32

Calc.Caption = far

Label2.Caption = "C"

Label3.Caption = "F"

End If

If Option2.Value = True Then


P a g e | 14

cen = 5 / 9 * (x - 32)

Calc.Caption = cen

Label2.Caption = "F"

Label3.Caption = "C"

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Calc.Caption = ""

Label2.Caption = ""

Label3.Caption = ""

End Sub

Private Sub Command3_Click()

End

End Sub

Form:
P a g e | 15

Output:
i)

ii)
P a g e | 16

Project No: 05
Create a project to find the sum of numbers from 1 to selected value.

Object View:

Program Code:
Private Sub Command1_Click()

Dim X, Y As Integer, SUM As Double

X = Val(Text1.Text)

Y=1

SUM = 0

Do While Y <= X

SUM = SUM + Y

Y=Y+1

Loop

Label2.Caption = SUM
P a g e | 17

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Label2.Caption = ""

End Sub

Private Sub END_Click()

End

End Sub

Form:
P a g e | 18

Output:
i)

ii)
P a g e | 19

Project No: 06
Create a project to find the simple interest.

Object View:

Program Code:
Private Sub Command1_Click()

Dim P, R, T, SI As Double

P = Val(Text1.Text)

R = Val(Text2.Text)

T = Val(Text3.Text)

SI = P * R * T / 100

Label2.Caption = SI

End Sub

Private Sub Command2_Click()


P a g e | 20

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Label2.Caption = ""

End Sub

Private Sub Command3_Click()

End

End Sub

Form:
P a g e | 21

Output:
i)

ii)
P a g e | 22

Project No: 07
Create a project to make a calculator.

Object View:

Program Code:
Dim op As Integer

Dim fn, per As Double

Private Sub Command1_Click()

Label2.Caption = Label2.Caption & 7

End Sub

Private Sub Command2_Click()

Label2.Caption = Label2.Caption & 8

End Sub

Private Sub Command3_Click()


P a g e | 23

Label2.Caption = Label2.Caption & 9

End Sub

Private Sub Command4_Click()

Label2.Caption = Label2.Caption & 4

End Sub

Private Sub Command5_Click()

Label2.Caption = Label2.Caption & 5

End Sub

Private Sub Command6_Click()

Label2.Caption = Label2.Caption & 6

End Sub

Private Sub Command7_Click()

Label2.Caption = Label2.Caption & 1

End Sub

Private Sub Command8_Click()

Label2.Caption = Label2.Caption & 2

End Sub

Private Sub Command9_Click()

Label2.Caption = Label2.Caption & 3

End Sub
P a g e | 24

Private Sub Command10_Click()

Label2.Caption = Label2.Caption & 0

End Sub

Private Sub Command11_Click()

Label2.Caption = Label2.Caption & "."

End Sub

Private Sub Command12_Click()

per = Label2.Caption

Label2.Caption = Val(per) / 100

fn = Label2.Caption

End Sub

Private Sub Command15_Click()

op = 2

fn = Label2.Caption

Label2.Caption = ""

End Sub

Private Sub Command16_Click()

op = 3

fn = Label2.Caption

Label2.Caption = ""

End Sub
P a g e | 25

Private Sub Command17_Click()

op = 4

fn = Label2.Caption

Label2.Caption = ""

End Sub

Private Sub Command18_Click()

op = 1

fn = Label2.Caption

Label2.Caption = ""

End Sub

Private Sub Command19_Click()

If op = 1 Then

Label2.Caption = Val(fn) + Val(Label2.Caption)

ElseIf op = 2 Then

Label2.Caption = Val(fn) - Val(Label2.Caption)

ElseIf op = 3 Then

Label2.Caption = Val(fn) * Val(Label2.Caption)

ElseIf op = 4 Then

Label2.Caption = Val(fn) / Val(Label2.Caption)

End If

End Sub

Private Sub Command13_Click()

Label2.Caption = ""
P a g e | 26

End Sub

Private Sub Command14_Click()

Unload Me

End Sub

Form:

Output:

Input taken: 12.5


P a g e | 27

Multiplied by 5

Output
P a g e | 28

Project No: 08
Create a project to convert a text from uppercase to lowercase and vice versa.

Object View:

Program Code:
Private Sub Command1_Click()

If Option1.Value = True Then

Label1.Caption = LCase(Text1.Text)

ElseIf Option2.Value = True Then

Label1.Caption = UCase(Text1.Text)

End If

End Sub

Private Sub Command2_Click()


P a g e | 29

Text1.Text = ""

Label1.Caption = ""

End Sub

Private Sub Command3_Click()

Unload Me

End Sub

Form:
P a g e | 30

Output:
i)

Upper to lower

ii)

Lower to upper
P a g e | 31

Project No: 09
Create a project to make a gradation (like A, B, C, D and E) based on total marks
providing the marks of different subjects.

Object View:

Program Code:
Private Sub Command1_Click()

Dim Eng, Phys, Math, Cms, Chem, Avj As Double

Eng = Val(Text2.Text)

Phys = Val(Text3.Text)

Math = Val(Text4.Text)

Cms = Val(Text5.Text)

Chem = Val(Text6.Text)

Label_fm.Caption = 500

Label_total.Caption = Eng + Phys + Math + Cms + Chem


P a g e | 32

Avj = Val(Label_total.Caption) / 5

If Avj > 100 Then

Label_total.Caption = ""

Label_grade.Caption = ""

MsgBox "A candidate can't obtain more than 100 marks in a subject"

ElseIf Avj >= 80 Then

Label_grade = "A"

ElseIf Avj >= 60 Then

Label_grade = "B"

ElseIf Avj >= 50 Then

Label_grade = "C"

ElseIf Avj >= 40 Then

Label_grade = "D"

ElseIf Avj >= 30 Then

Label_grade = "E"

ElseIf Avj >= 0 Then

Label_grade = "F"

End If

End Sub

Private Sub Command2_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""
P a g e | 33

Text6.Text = ""

Label_fm.Caption = ""

Label_total.Caption = ""

Label_grade.Caption = ""

End Sub

Private Sub Command3_Click()

Unload Me

End Sub

Form:
P a g e | 34

Output:
i)

ii)

iii)

You might also like