YOU ARE DOWNLOADING DOCUMENT

Please tick the box to continue:

Transcript
Page 1: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 1/45

 

1 | P a g e  

Practical File  OF  

 VB

SUBMITTED TO : SUBMITTED BY :

Ms. Meena Ajay Sehrawat

(Asstt. Prof.) MCA 4tsem.

(Dept. of Comp. App.) Roll no………… 

VIASH INSTITUTE OF MANAGEMENT AND

TECHNOLOGY

Page 2: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 2/45

 

2 | P a g e  

INDEX 

Serial

No.

Concept Name Page

No.

Remarks

1. Write a program to calculate the average, sum and product of three

numbers.3-4

2. Write a program to calculate the Mathematical Calculation of two

numbers.5-6

3. Write a program to find the greatest of three numbers. 7-8

4. Write a program to find the factorial of a given number. 9-10

5. Write a program to find the sum and reverse of a given number. 11-12

6. Write a program to find the roots of a quadratic equation. 13-14

7. Write a program to illustrates the use of Select-case statement. 15-168. Write a program to illustrate the use of code module. 17-18

9. Write a program to find the factorial of a number using recursion. 19-20

10. Write a program to convert any string into upper and lower format. 21-22

11. Write a program to find the reverse of a given string using Mid$ and

Len function.23-24

12. Write a program to convert temperature to degrees Celsius and vice

versa.25-27

13. Write a program to display current date and time. 28-29

14. Write a program to illustrate the concept Error Handling. 30-31

15. Write a program to use the MDI forms. 32-34

16. Design an application to display the traffic light using Shape and

Timer controls.35-36

17. Write a program to illustrate the use of data or time function. 37-38

18. Write a program to illustrate the use of combo box. 39-40

19. Write a program to implement the Report in vb. 41

20. Write a program to implement the ACTIVE-X page.  42

21. Write a program to implement the data access object(DAO). 43-45

Page 3: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 3/45

 

3 | P a g e  

PROGRAM NO. 1.

‘Write a program to calculate the average, sum and product

of three numbers.

Private Sub Command1_Click()

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

End Sub

Private Sub Command2_Click()

Text4.Text = (Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text)) / 3

End Sub

Private Sub Command3_Click()

Text4.Text = Val(Text1.Text) * Val(Text2.Text) * Val(Text3.Text)

End Sub

Private Sub Command4_Click()

End

End Sub

Page 4: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 4/45

 

4 | P a g e  

OUTPUT :-

Page 5: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 5/45

 

5 | P a g e  

PROGRAM NO. 2.

Write a program to calculate the Mathematical Calculation

of two numbers.

Private Sub Command1_Click()

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

End Sub

Private Sub Command2_Click()

Text3.Text = Val(Text1.Text) - Val(Text2.Text)

End Sub

Private Sub Command3_Click()

Text3.Text = Val(Text1.Text) * Val(Text2.Text)

End Sub

Private Sub Command4_Click()

Text3.Text = Val(Text1.Text) / Val(Text2.Text)

End Sub

Private Sub Command5_Click()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

End Sub

Private Sub Command6_Click()

End

End Sub

Page 6: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 6/45

 

6 | P a g e  

OUTPUT :- 

Page 7: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 7/45

 

7 | P a g e  

PROGRAM NO. 3.

‘Write a program to find the greatest of three numbers.

Private Sub Command1_Click()

Dim a

Dim b

Dim c

a = Val(Text1.Text)

b = Val(Text2.Text)

c = Val(Text3.Text)

If a > b And a > c Then

Label4.Caption = "First number is Greater"

ElseIf b > c Then

Label4.Caption = "Second number is Greater"

Else

Label4.Caption = "Third number is Greater"

End If 

End Sub

Page 8: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 8/45

 

8 | P a g e  

OUTPUT :- 

Page 9: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 9/45

 

9 | P a g e  

PROGRAM NO. 4.

‘ Write a program to find the factorial of a given number.

Private Sub Command1_Click()

Dim fact As Integer, i As Integer

fact = 1

For i = 1 To Val(Text1.Text)

fact = fact * i

Next i

Text2.Text = fact

End Sub

Page 10: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 10/45

 

10 | P a g e  

OUTPUT :- 

Page 11: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 11/45

 

11 | P a g e  

PROGRAM NO. 5. 

‘ Write a program to find the sum and reverse of a given number.

Private Sub Command1_Click()

Dim n As Integer, a As Integer, num As Integer, sum As Integer

n = Val(Text3.Text)

sum = 0

num = 0

Do While n <> 0

a = n Mod 10

num = num * 10 + a

sum = sum + a

Loop

Text1.Text = num

Text2.Text = sum

End Sub

Page 12: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 12/45

 

12 | P a g e  

OUTPUT :- 

Page 13: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 13/45

 

13 | P a g e  

PROGRAM NO. 6. 

‘Write a program to find the roots of a quadratic equation.

Private Sub Command1_Click()

Dim a As Double, b As Double, c As Double, d As Double

a = Val(Text1.Text)

b = Val(Text2.Text)

c = Val(Text3.Text)

d = b ^ 2 - 4 * a * c

If (d < 0) Then

Label4.Caption = "The roots are imaginary"

Else

If d = 0 Then

Label4.Caption = "The roots are equal"

Text4.Text = (-b + Sqr(d)) / (2 * a)

Text5.Text = Text4.Text

Else

Label4.Caption = "The roots are real"

Text4.Text = (-b + Sqr(d)) / (2 * a)

Text5.Text = (-b - Sqr(d)) / (2 * a)

End If 

End If 

End Sub

Page 14: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 14/45

 

14 | P a g e  

OUTPUT :-

 

Page 15: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 15/45

 

15 | P a g e  

PROGRAM NO. 7. 

‘Write a program to illustrates the use of Select-case statement.

Private Sub Command1_Click()

Dim per As Integer

per = Val(Text1.Text)

Select Case per

Case Is >= 90

Label2.Caption = "Grade is A"

Case Is >= 80

Label2.Caption = "Grade is B"

Case Is >= 70

Label2.Caption = "Grade is C"

Case Is >= 60

Label2.Caption = "Grade is D"

Case Else

Label2.Caption = "Grade is F"

End Select

End Sub

Page 16: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 16/45

 

16 | P a g e  

OUTPUT :-

 

Page 17: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 17/45

 

17 | P a g e  

PROGRAM NO. 8. 

‘Write a program to illustrate the use of code module.

Option Explicit

Private Sub Command1_Click()

Call moduleSum

End Sub

Option Explicit

Public Sub moduleSum()

Dim i As Integer

Form1.Print "Natural number 1 to 20 in module"

For i = 1 To 20

Form1.Print i

Next i

End Sub

Page 18: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 18/45

 

18 | P a g e  

OUTPUT :-

 

Page 19: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 19/45

 

19 | P a g e  

PROGRAM NO. 9. 

‘Write a program to find the factorial of a number using recursion. 

Private Sub Command1_Click()

Dim n As Integer, i As Integer

List1.Clear

n = Val(Text1.Text)

For i = 0 To n

List1.AddItem i & "!=" & Factorial((i))

Next i

End Sub

Private Function Factorial(ByVal j As Integer) As Integer

If j <= 1 Then

Factorial = 1

Else

Factorial = j * Factorial(j - 1)

End If 

End Function

Page 20: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 20/45

 

20 | P a g e  

OUTPUT :- 

Page 21: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 21/45

 

21 | P a g e  

PROGRAM NO. 10. 

‘Write a program to convert any string into upper and lower format. 

Private Sub Command1_Click()

Text2.Text = LCase$(Text1.Text)

Text3.Text = UCase$(Text1.Text)

End Sub

Page 22: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 22/45

 

22 | P a g e  

OUTPUT :- 

Page 23: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 23/45

 

23 | P a g e  

PROGRAM NO. 11. 

Write a program to find the reverse of a given string using

Mid$ and Len function . 

Private Sub Command1_Click()

Dim str As String, pas As Integer

Text2.Text = ""

str = Text1.Text

For pas = Len(str) To 1 Step -1

Text2.Text = Text2.Text & Mid$(str, pas, 1)

Next

End Sub

Page 24: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 24/45

 

24 | P a g e  

OUTPUT :- 

Page 25: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 25/45

 

25 | P a g e  

PROGRAM NO. 12. 

‘Write a program to convert temperature to degrees Celsius and vice versa. 

Private Sub Command1_Click()

Dim temp As Double, temp1 As Double

temp = Val(Text1.Text)

If Option1 = True Then

temp1 = (5 / 9) * (temp - 32)

Else

temp1 = (1.8 * temp + 32)

End If 

Text2.Text = temp1

End Sub

Private Sub Command2_Click()

End

End Sub

Private Sub Option1_Click()

If (Option1.Value = True) Then

Label1.Caption = "Enter original temperature in degrees Fahrenheit"

Text1.Text = ""

Label2.Caption = "Equivalent temperature in degrees Celsius"

Text2.Text = ""

Page 26: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 26/45

 

26 | P a g e  

End If 

End Sub

Private Sub Option2_Click()

If (Option2.Value = True) Then

Label1.Caption = "Enter original temperature in degrees Celsius"

Text1.Text = ""

Label2.Caption = "Equivalent temperature in degrees Fahrenheit"

Text2.Text = ""

End If 

End Sub

Page 27: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 27/45

 

27 | P a g e  

OUTPUT :- 

Page 28: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 28/45

 

28 | P a g e  

PROGRAM NO. 13. 

‘Write a program to display current date and time. 

Option Explicit

Private Sub Timer1_Timer()

If Form1.WindowState = vbNormal Then

Label1.Caption = CStr(Time)

Form1.Caption = Format(Date, "Long Date")

Else

Form1.Caption = CStr(Time)

End If 

End Sub

Page 29: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 29/45

 

29 | P a g e  

OUTPUT :- 

Page 30: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 30/45

 

30 | P a g e  

PROGRAM NO. 14. 

‘Write a program to illustrate the concept Error Handling. 

Private Sub Command1_Click()

Dim n As Integer, fact As Integer

n = Val(Text1)

fact = 1

For i = 1 To n

fact = fact * i

On Error GoTo overflow

Next i

Label2.Caption = "Factorial is :" & Str(fact)

overflow:

If n >= 8 Then

MsgBox "Numeric OverFlow"

End If 

End Sub

Page 31: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 31/45

 

31 | P a g e  

OUTPUT :- 

Page 32: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 32/45

 

32 | P a g e  

PROGRAM NO. 15. 

‘Write a program to use the MDI forms. 

Private Sub ba_Click()

Me.Hide

frmbang.Show

End Sub

Private Sub ca_Click()

Me.Arrange vbCascade

End Sub

Private Sub ex_Click()

End

End Sub

Private Sub ho_Click()

Me.Arrange vbTileHorizontal

End Sub

Private Sub in_Click()

Me.Hide

frmindia.Show

End Sub

Private Sub pa_Click()

Me.Hide

frmpak.Show

End Sub

Page 33: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 33/45

 

33 | P a g e  

Private Sub sr_Click()

Me.Hide

frnsri.Show

End Sub

Private Sub ve_Click()

Me.Arrange vbTileVertical

End Sub

Private Sub Text1_Change()

Text1.Text = "hi rawan"

End Sub

Private Sub Text1_Change()

Text1.Text = "i hate pakistani"

End Sub

Private Sub Text1_Change()

Text1.Text = "i love my india"

End Sub

Private Sub Text1_Change()

Text1.Text = "hi bango"

End Sub

Page 34: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 34/45

 

34 | P a g e  

OUTPUT :- 

Page 35: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 35/45

 

35 | P a g e  

PROGRAM NO. 16. 

‘Design an application to display the traffic light using

Shape and Timer controls. 

Private Sub Timer1_Timer()

Static state As Integer

Select Case state

Case 0

shpred.BackColor = vbRed

shpyellow.BackColor = vbWhite

shpgreen.BackColor = vbWhite

lblmsg.Caption = "Stop"

Timer1.Interval = 7000

state = 1

Case 1

shpred.BackColor = vbWhite

shpyellow.BackColor = vbYellow

shpgreen.BackColor = vbWhite

lblmsg.Caption = "Wait"

Timer1.Interval = 2000 state = 2

Case 2 shpred.BackColor = vbWhite

shpyellow.BackColor = vbWhite

shpgreen.BackColor = vbGreen

lblmsg.Caption = "Go"

Timer1.Interval = 5000

state = 0 End Select End Sub

Page 36: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 36/45

 

36 | P a g e  

OUTPUT :- 

Page 37: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 37/45

 

37 | P a g e  

PROGRAM NO. 17. 

‘Write a program to illustrate the use of data or time function.

Private Sub Command1_Click()

List1.AddItem ("Current date and time :" & Now)

List1.AddItem ("Date :" & Date)

List1.AddItem ("Day :" & Day(Date))

List1.AddItem ("Week day :" & Weekday(Date))

List1.AddItem ("Week Day Name :" & WeekdayName(Weekday(Date)))

List1.AddItem (" Month:" & Month(Date))

List1.AddItem ("Month Name:" & MonthName(Month(Date)))

List1.AddItem ("Year :" & Year(Date))

List1.AddItem (#3/2/1976#)

End Sub

Page 38: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 38/45

 

38 | P a g e  

OUTPUT :-

 

Page 39: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 39/45

 

39 | P a g e  

PROGRAM NO. 18. 

‘Write a program to illustrate the use of combo box.

Private Sub Form_Load()

Combo1.AddItem "Ajay"

Combo1.AddItem "Sandeep"

Combo1.AddItem "Deepak"

Combo1.AddItem "Krishan"

End Sub

Private Sub Combo1_Click()

If Combo1.Text = "Ajay" Then

Text1.Text = "Designation -Clerk,Salary Rs.25000"

End If 

If Combo1.Text = "Sandeep" Then

Text1.Text = "Designation -Sales Man,Salary Rs.24000"

End If 

If Combo1.Text = "Deepak" Then

Text1.Text = "Designation -Manager,Salary Rs.20000"

End If 

If Combo1.Text = "Krishan" Then

Text1.Text = "Designation -Clerk,Salary Rs.2000"

End If 

End Sub

Page 40: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 40/45

 

40 | P a g e  

OUTPUT :-

Page 41: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 41/45

 

41 | P a g e  

PROGRAM NO. 19.

‘Write a program to implement the REPORT in vb. 

Private Sub Command1_Click()

DataReport1.Show

End Sub

OUTPUT:-

Page 42: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 42/45

 

42 | P a g e  

PROGRAM NO 20.

‘Write a program to implement the ACTIVE-X page.

Private Sub Command1_Click()

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

End Sub

OUTPUT :-

Page 43: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 43/45

 

43 | P a g e  

PROGRAM NO 21.

‘Write a program to implement the data access object(DAO). 

Private Sub Command1_Click()

'Move to first record

datbooks.Recordset.MoveFirst

End Sub

Private Sub Command2_Click()

'move to previous record

With datbooks.Recordset

.MovePrevious

If .BOF Then

.MoveLast

End If 

End With

End Sub

Private Sub Command3_Click()

'mover to first record

datbooks.Recordset.MoveFirst

End Sub

Private Sub Command4_Click()

'move to last record

datbooks.Recordset.MoveLast

End Sub

Page 44: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 44/45

 

44 | P a g e  

Private Sub Command5_Click()

'Add a new record

datbooks.Recordset.AddNew 'Clear out fields for new record

End Sub

Private Sub Command7_Click()

'Delete the current record

With datbooks.Recordset

.Delete

.MoveNext

If .EOF Then

.MovePrevious

End If 

End With

End Sub

Page 45: VB File Print Report

7/16/2019 VB File Print Report

http://slidepdf.com/reader/full/vb-file-print-report 45/45

 

OUTPUT :-


Related Documents