vbreport

39
Program 1 Printing Series Code Private Sub Form_Click() For k = 1 To 5 Print k Next End Sub Output 1 | Page

Upload: shweta-sharma99

Post on 12-May-2015

2.047 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Vbreport

Program 1

Printing Series

Code

Private Sub Form_Click()

For k = 1 To 5

Print k

Next

End Sub

Output

1 | P a g e

Page 2: Vbreport

Program 2

Printing Triangle Series

Code

Private Sub Form_Click()

For r = 1 To 5

For c = 1 To r

Print c;

Next

Print

Next

End Sub

Output

2 | P a g e

Page 3: Vbreport

Program 3

Printing Reverse triangle series

Code

Private Sub Form_Click()

For r = 5 To 1 Step -1

For c = 1 To r

Print c;

Next

Print

Next

End Sub

Output

3 | P a g e

Page 4: Vbreport

Program 4

Multiply Two Numbers

Code

Private Sub Command1_Click()

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

End Sub

Private Sub Form_Load()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

End Sub

Output

4 | P a g e

Page 5: Vbreport

Program 5

Printing Pyramid Series

Code

Private Sub Form_Click()

For r = 1 To 5

For k = 4 To r Step -1

Print " ";

Next

For c = 1 To r

Print c;

Next

For d = r - 1 To 1 Step -1

Print d;

Next

Print

Next

End Sub

5 | P a g e

Page 6: Vbreport

Output

6 | P a g e

Page 7: Vbreport

Program 6

Simple Calculator

Code

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

7 | P a g e

Page 8: Vbreport

Output

8 | P a g e

Page 9: Vbreport

Program 7

Timer Control

Code

Private Sub Timer1_Timer()

Command1.Left = Command1.Left + 10

If Command1.Left = 9840 Then

Timer1.Enabled = False

Timer2.Enabled = True

End If

End Sub

Private Sub Timer2_Timer()

Command1.Top = Command1.Top + 10

If Command1.Top = 9000 Then

Timer2.Enabled = False

Timer3.Enabled = True

End If

End Sub

Private Sub Timer3_Timer()

9 | P a g e

Page 10: Vbreport

Command1.Left = Command1.Left - 10

If Command1.Left = 0 Then

Timer3.Enabled = False

Timer4.Enabled = True

End If

End Sub

Private Sub Timer4_Timer()

Command1.Top = Command1.Top - 10

If Command1.Top = 0 Then

Timer4.Enabled = False

Timer1.Enabled = True

End If

End Sub

Private Sub Timer5_Timer()

Command2.Top = Command2.Top + 10

If Command2.Top = 9000 Then

Timer5.Enabled = False

Timer6.Enabled = True

End If

10 | P a g e

Page 11: Vbreport

End Sub

Private Sub Timer6_Timer()

Command2.Left = Command2.Left + 10

If Command2.Left = 9840 Then

Timer6.Enabled = False

Timer7.Enabled = True

End If

End Sub

Private Sub Timer7_Timer()

Command2.Top = Command2.Top - 10

If Command2.Top = 0 Then

Timer7.Enabled = False

Timer8.Enabled = True

End If

End Sub

Private Sub Timer8_Timer()

Command2.Left = Command2.Left - 10

If Command2.Left = 0 Then

11 | P a g e

Page 12: Vbreport

Timer8.Enabled = False

Timer5.Enabled = True

End If

End Sub

Output

12 | P a g e

Page 13: Vbreport

Program 8

Chech Box And Option Button

Code

Private Sub Check1_Click()

If Check1.Value = 1 Then

Text1.FontBold = True

ElseIf Check1.Value = 0 Then

Text1.FontBold = False

End If

End Sub

Private Sub Check2_Click()

If Check2.Value = 1 Then

Text1.FontItalic = True

ElseIf Check2.Value = 0 Then

Text1.FontItalic = False

End If

End Sub

Private Sub Check3_Click()

13 | P a g e

Page 14: Vbreport

If Check3.Value = 1 Then

Text1.FontUnderline = True

ElseIf Check3.Value = 0 Then

Text1.FontUnderline = False

End If

End Sub

Private Sub Option1_Click()

If Option1.Value = True Then

Text1.BackColor = vbBlue

End If

End Sub

Private Sub Option2_Click()

If Option2.Value = True Then

Text1.BackColor = vbGreen

End If

End Sub

Private Sub Option3_Click()

If Option3.Value = True Then

14 | P a g e

Page 15: Vbreport

Text1.BackColor = vbYellow

End If

End Sub

Output

15 | P a g e

Page 16: Vbreport

Program 9

Combo Box

Code

Private Sub Combo1_Click()

If Combo1.ListIndex = 0 Then

Text1.FontName = Combo1.Text

ElseIf Combo1.ListIndex = 1 Then

Text1.FontName = Combo1.Text

ElseIf Combo1.ListIndex = 2 Then

Text1.FontName = Combo1.Text

ElseIf Combo1.ListIndex = 3 Then

Text1.FontName = Combo1.Text

ElseIf Combo1.ListIndex = 4 Then

Text1.FontName = Combo1.Text

ElseIf Combo1.ListIndex = 5 Then

Text1.FontName = Combo1.Text

ElseIf Combo1.ListIndex = 6 Then

Text1.FontName = Combo1.Text

End If

End Sub

16 | P a g e

Page 17: Vbreport

Private Sub Combo2_Click()

If Combo2.ListIndex = 0 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 1 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 2 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 3 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 4 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 5 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 6 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 7 Then

Text1.FontSize = Combo2.Text

ElseIf Combo2.ListIndex = 8 Then

Text1.FontSize = Combo2.Text

End If

17 | P a g e

Page 18: Vbreport

End Sub

Private Sub Form_Load()

Combo1.AddItem "Times New Roman"

Combo1.AddItem "Arial Black"

Combo1.AddItem "Batang"

Combo1.AddItem "Century"

Combo1.AddItem "Courier New"

Combo1.AddItem "impact"

Combo1.AddItem "Lucida Console"

End Sub

Output

18 | P a g e

Page 19: Vbreport

Program 10

Calculating Student Result

Code

Private Sub Combo3_Click()

If Combo3.ListIndex = 0 Then

Label3.Caption = "data strcture"

Label4.Caption = "visual basic"

Label5.Caption = "database"

Else

Label3.Caption = "accounts"

Label4.Caption = "MIS"

Label5.Caption = "economics"

End If

End Sub

Private Sub Command1_Click()

Label12.Caption = Text1.Text

Label14.Caption = Text2.Text

Label16.Caption = Text4.Text

Label18.Caption = Label3.Caption

19 | P a g e

Page 20: Vbreport

Label19.Caption = Label4.Caption

Label20.Caption = Label5.Caption

Label16.Caption = Label5.Caption

Label17.Caption = Combo3.Text

Label21.Caption = Text3.Text

Label22.Caption = Text5.Text

Label23.Caption = Text6.Text

Label25.Caption = Val(Text3.Text) + Val(Text5.Text) + Val(Text6.Text)

Text7.Text = ((Val(Text3.Text) + Val(Text5.Text) + Val(Text6.Text)) * 100) / 300

If Val(Text7.Text) >= 80 Then

Label29.Caption = "merit"

ElseIf Val(Text7.Text) >= 60 Then

Label29.Caption = "firstclass"

ElseIf Val(Text7.Text) >= 33 Then

Label29.Caption = "pass"

Else

Label29.Caption = "fail"

End If

End Sub

20 | P a g e

Page 21: Vbreport

Private Sub Form_Load()

Text1.Text = ""

Text2.Text = ""

Text3.Text = ""

Text4.Text = ""

Text5.Text = ""

Text6.Text = ""

End Sub

Output

21 | P a g e

Page 22: Vbreport

Program 11

Paint Functions

Code

Private Sub Command1_Click()

Form1.Cls

End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)

Form1.CurrentX = X

Form1.CurrentY = Y

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If Button = 1 Then

'Line (X, Y)-(CurrentX, CurrentY)

Circle (X, Y), 700

End If

End Sub

22 | P a g e

Page 23: Vbreport

Output

23 | P a g e

Page 24: Vbreport

Program 12

Puzzle Game

Code

Private Sub Command1_Click()

If Command2.Caption = "" Then

Command2.Caption = Command1.Caption

Command1.Caption = ""

ElseIf Command4.Caption = "" Then

Command4.Caption = Command1.Caption

Command1.Caption = ""

End If

End Sub

Private Sub Command10_Click()

Command1.Caption = 1

Command2.Caption = 2

Command3.Caption = 3

Command4.Caption = 4

Command5.Caption = 5

Command6.Caption = 6

24 | P a g e

Page 25: Vbreport

Command7.Caption = 7

Command8.Caption = 8

Command9.Caption = ""

End Sub

Private Sub Command2_Click()

If Command1.Caption = "" Then

Command1.Caption = Command2.Caption

Command2.Caption = ""

ElseIf Command3.Caption = "" Then

Command3.Caption = Command2.Caption

Command2.Caption = ""

ElseIf Command5.Caption = "" Then

Command5.Caption = Command2.Caption

Command2.Caption = ""

End If

End Sub

Private Sub Command3_Click()

If Command2.Caption = "" Then

Command2.Caption = Command3.Caption

25 | P a g e

Page 26: Vbreport

Command3.Caption = ""

ElseIf Command6.Caption = "" Then

Command6.Caption = Command3.Caption

Command3.Caption = ""

End If

End Sub

Private Sub Command4_Click()

If Command1.Caption = "" Then

Command1.Caption = Command4.Caption

Command4.Caption = ""

ElseIf Command7.Caption = "" Then

Command7.Caption = Command4.Caption

Command4.Caption = ""

ElseIf Command5.Caption = "" Then

Command5.Caption = Command4.Caption

Command4.Caption = ""

End If

End Sub

Private Sub Command5_Click()

26 | P a g e

Page 27: Vbreport

If Command2.Caption = "" Then

Command2.Caption = Command5.Caption

Command5.Caption = ""

ElseIf Command4.Caption = "" Then

Command4.Caption = Command5.Caption

Command5.Caption = ""

ElseIf Command8.Caption = "" Then

Command8.Caption = Command5.Caption

Command5.Caption = ""

ElseIf Command6.Caption = "" Then

Command6.Caption = Command5.Caption

Command5.Caption = ""

End If

End Sub

Private Sub Command6_Click()

If Command3.Caption = "" Then

Command3.Caption = Command6.Caption

Command6.Caption = ""

ElseIf Command9.Caption = "" Then

Command9.Caption = Command6.Caption

27 | P a g e

Page 28: Vbreport

Command6.Caption = ""

End If

End Sub

Private Sub Command7_Click()

If Command4.Caption = "" Then

Command4.Caption = Command7.Caption

Command7.Caption = ""

ElseIf Command8.Caption = "" Then

Command8.Caption = Command7.Caption

Command7.Caption = ""

End If

End Sub

Private Sub Command8_Click()

If Command7.Caption = "" Then

Command7.Caption = Command8.Caption

Command8.Caption = ""

ElseIf Command5.Caption = "" Then

Command5.Caption = Command8.Caption

Command8.Caption = ""

28 | P a g e

Page 29: Vbreport

ElseIf Command9.Caption = "" Then

Command9.Caption = Command8.Caption

Command8.Caption = ""

End If

End Sub

Private Sub Command9_Click()

If Command8.Caption = "" Then

Command8.Caption = Command9.Caption

Command9.Caption = ""

ElseIf Command6.Caption = "" Then

Command6.Caption = Command9.Caption

Command9.Caption = ""

End If

End Sub

29 | P a g e

Page 30: Vbreport

Output

30 | P a g e

Page 31: Vbreport

Program 13

MENU BAR

Code

Private Sub Blue_Click()

Form1.BackColor = vbBlue

End Sub

Private Sub Exit_Click()

Unload Me

End Sub

Private Sub Green_Click()

Form1.BackColor = vbGreen

End Sub

Private Sub Maximize_Click()

Form1.WindowState = 2

End Sub

Private Sub Minimize_Click()

Form1.WindowState = 1

31 | P a g e

Page 32: Vbreport

End Sub

Private Sub Red_Click()

Form1.BackColor = vbRed

End Sub

Private Sub Restore_Click()

Form1.WindowState = 0

End Sub

32 | P a g e

Page 33: Vbreport

Output

33 | P a g e