ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
1 | P a g e
Program 1
Printing Series
? Code
Private Sub Form_Click()
For k = 1 To 5
Print k
Next
End Sub
? Output
2 | P a g e
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
3 | P a g e
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
4 | P a g e
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
5 | P a g e
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
6 | P a g e
? Output
7 | P a g e
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
8 | P a g e
? Output
9 | P a g e
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()
10 | P a g e
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
11 | P a g e
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
12 | P a g e
Timer8.Enabled = False
Timer5.Enabled = True
End If
End Sub
? Output
13 | P a g e
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()
14 | P a g e
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
15 | P a g e
Text1.BackColor = vbYellow
End If
End Sub
? Output
16 | P a g e
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
17 | P a g e
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
18 | P a g e
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
19 | P a g e
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
20 | P a g e
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
21 | P a g e
Private Sub Form_Load()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
? Output
22 | P a g e
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
23 | P a g e
? Output
24 | P a g e
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
25 | P a g e
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
26 | P a g e
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()
27 | P a g e
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
28 | P a g e
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 = ""
29 | P a g e
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
30 | P a g e
? Output
31 | P a g e
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
32 | P a g e
End Sub
Private Sub Red_Click()
Form1.BackColor = vbRed
End Sub
Private Sub Restore_Click()
Form1.WindowState = 0
End Sub
33 | P a g e
? Output

More Related Content

Vbreport program

  • 1. 1 | P a g e Program 1 Printing Series ? Code Private Sub Form_Click() For k = 1 To 5 Print k Next End Sub ? Output
  • 2. 2 | P a g e 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
  • 3. 3 | P a g e 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
  • 4. 4 | P a g e 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
  • 5. 5 | P a g e 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
  • 6. 6 | P a g e ? Output
  • 7. 7 | P a g e 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
  • 8. 8 | P a g e ? Output
  • 9. 9 | P a g e 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()
  • 10. 10 | P a g e 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
  • 11. 11 | P a g e 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
  • 12. 12 | P a g e Timer8.Enabled = False Timer5.Enabled = True End If End Sub ? Output
  • 13. 13 | P a g e 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()
  • 14. 14 | P a g e 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
  • 15. 15 | P a g e Text1.BackColor = vbYellow End If End Sub ? Output
  • 16. 16 | P a g e 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
  • 17. 17 | P a g e 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
  • 18. 18 | P a g e 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
  • 19. 19 | P a g e 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
  • 20. 20 | P a g e 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
  • 21. 21 | P a g e Private Sub Form_Load() Text1.Text = "" Text2.Text = "" Text3.Text = "" Text4.Text = "" Text5.Text = "" Text6.Text = "" End Sub ? Output
  • 22. 22 | P a g e 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
  • 23. 23 | P a g e ? Output
  • 24. 24 | P a g e 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
  • 25. 25 | P a g e 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
  • 26. 26 | P a g e 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()
  • 27. 27 | P a g e 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
  • 28. 28 | P a g e 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 = ""
  • 29. 29 | P a g e 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
  • 30. 30 | P a g e ? Output
  • 31. 31 | P a g e 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
  • 32. 32 | P a g e End Sub Private Sub Red_Click() Form1.BackColor = vbRed End Sub Private Sub Restore_Click() Form1.WindowState = 0 End Sub
  • 33. 33 | P a g e ? Output