SlideShare a Scribd company logo
1 of 33
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

Viewers also liked

Ebooktiketkapal
EbooktiketkapalEbooktiketkapal
Ebooktiketkapaldhi her
 
Dasarpemrogramanvisualbasic
DasarpemrogramanvisualbasicDasarpemrogramanvisualbasic
Dasarpemrogramanvisualbasicdhi her
 
visualbasicprograming
visualbasicprogramingvisualbasicprograming
visualbasicprogramingdhi her
 
Modulpelatihanmikrotik
ModulpelatihanmikrotikModulpelatihanmikrotik
Modulpelatihanmikrotikdhi her
 
Dasarpemrogramanvisualbasic
DasarpemrogramanvisualbasicDasarpemrogramanvisualbasic
Dasarpemrogramanvisualbasicdhi her
 
Uu no-13-tahun-2003
Uu no-13-tahun-2003Uu no-13-tahun-2003
Uu no-13-tahun-2003dhi her
 
Mikrotikrb750modulbeta
Mikrotikrb750modulbetaMikrotikrb750modulbeta
Mikrotikrb750modulbetadhi her
 

Viewers also liked (8)

Ebooktiketkapal
EbooktiketkapalEbooktiketkapal
Ebooktiketkapal
 
Dasarpemrogramanvisualbasic
DasarpemrogramanvisualbasicDasarpemrogramanvisualbasic
Dasarpemrogramanvisualbasic
 
№123
№123№123
№123
 
visualbasicprograming
visualbasicprogramingvisualbasicprograming
visualbasicprograming
 
Modulpelatihanmikrotik
ModulpelatihanmikrotikModulpelatihanmikrotik
Modulpelatihanmikrotik
 
Dasarpemrogramanvisualbasic
DasarpemrogramanvisualbasicDasarpemrogramanvisualbasic
Dasarpemrogramanvisualbasic
 
Uu no-13-tahun-2003
Uu no-13-tahun-2003Uu no-13-tahun-2003
Uu no-13-tahun-2003
 
Mikrotikrb750modulbeta
Mikrotikrb750modulbetaMikrotikrb750modulbeta
Mikrotikrb750modulbeta
 

Similar to Visual Basic Programming Examples

Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Yeardezyneecole
 
19.Advanced Visual Basic Lab.pdf
19.Advanced Visual Basic Lab.pdf19.Advanced Visual Basic Lab.pdf
19.Advanced Visual Basic Lab.pdfvirox10x
 
Reshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third YearReshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third Yeardezyneecole
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearDezyneecole
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearDezyneecole
 
Kajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third YearKajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third YearDezyneecole
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1rajnidhiman
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSKate Campbell
 
Trabajo de ept lissethe toro
Trabajo de ept lissethe toroTrabajo de ept lissethe toro
Trabajo de ept lissethe torolissethee
 
Sudarshan Joshi , BCA Third Year
Sudarshan Joshi , BCA Third YearSudarshan Joshi , BCA Third Year
Sudarshan Joshi , BCA Third Yeardezyneecole
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa Thapa
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONvikram mahendra
 
Harendra Singh,BCA Third Year
Harendra Singh,BCA Third YearHarendra Singh,BCA Third Year
Harendra Singh,BCA Third Yeardezyneecole
 

Similar to Visual Basic Programming Examples (20)

Vb file
Vb fileVb file
Vb file
 
Kirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third YearKirti Kumawat, BCA Third Year
Kirti Kumawat, BCA Third Year
 
19.Advanced Visual Basic Lab.pdf
19.Advanced Visual Basic Lab.pdf19.Advanced Visual Basic Lab.pdf
19.Advanced Visual Basic Lab.pdf
 
Reshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third YearReshma Kodwani , BCA Third Year
Reshma Kodwani , BCA Third Year
 
Loops in Python.pptx
Loops in Python.pptxLoops in Python.pptx
Loops in Python.pptx
 
Python for Beginners(v2)
Python for Beginners(v2)Python for Beginners(v2)
Python for Beginners(v2)
 
Ict project pdf
Ict project pdfIct project pdf
Ict project pdf
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
Bhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third YearBhanu Pratap Singh Shekhawat, BCA Third Year
Bhanu Pratap Singh Shekhawat, BCA Third Year
 
Pooja Sharma , BCA Third Year
Pooja Sharma , BCA Third YearPooja Sharma , BCA Third Year
Pooja Sharma , BCA Third Year
 
Kajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third YearKajal Gaharwal , BCA Third Year
Kajal Gaharwal , BCA Third Year
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
 
Trabajo de ept lissethe toro
Trabajo de ept lissethe toroTrabajo de ept lissethe toro
Trabajo de ept lissethe toro
 
Sudarshan Joshi , BCA Third Year
Sudarshan Joshi , BCA Third YearSudarshan Joshi , BCA Third Year
Sudarshan Joshi , BCA Third Year
 
Bikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptxBikalpa_Thapa_Python_Programming_(Basics).pptx
Bikalpa_Thapa_Python_Programming_(Basics).pptx
 
Listing program
Listing programListing program
Listing program
 
USER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHONUSER DEFINE FUNCTIONS IN PYTHON
USER DEFINE FUNCTIONS IN PYTHON
 
Harendra Singh,BCA Third Year
Harendra Singh,BCA Third YearHarendra Singh,BCA Third Year
Harendra Singh,BCA Third Year
 

More from dhi her

Tutorial mikrotik-1
Tutorial mikrotik-1Tutorial mikrotik-1
Tutorial mikrotik-1dhi her
 
Setting buat-router-mikrotik-
Setting buat-router-mikrotik-Setting buat-router-mikrotik-
Setting buat-router-mikrotik-dhi her
 
Panduansettingdialupspeedydenganroutermikrotik
PanduansettingdialupspeedydenganroutermikrotikPanduansettingdialupspeedydenganroutermikrotik
Panduansettingdialupspeedydenganroutermikrotikdhi her
 
Modulpelatihanp4tkmikrotik
Modulpelatihanp4tkmikrotikModulpelatihanp4tkmikrotik
Modulpelatihanp4tkmikrotikdhi her
 
Manualmikrotik
ManualmikrotikManualmikrotik
Manualmikrotikdhi her
 
Tutorial mikrotik-2
Tutorial mikrotik-2Tutorial mikrotik-2
Tutorial mikrotik-2dhi her
 
Vbtutorial
VbtutorialVbtutorial
Vbtutorialdhi her
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshopdhi her
 
Ebookrentalfilm
EbookrentalfilmEbookrentalfilm
Ebookrentalfilmdhi her
 

More from dhi her (9)

Tutorial mikrotik-1
Tutorial mikrotik-1Tutorial mikrotik-1
Tutorial mikrotik-1
 
Setting buat-router-mikrotik-
Setting buat-router-mikrotik-Setting buat-router-mikrotik-
Setting buat-router-mikrotik-
 
Panduansettingdialupspeedydenganroutermikrotik
PanduansettingdialupspeedydenganroutermikrotikPanduansettingdialupspeedydenganroutermikrotik
Panduansettingdialupspeedydenganroutermikrotik
 
Modulpelatihanp4tkmikrotik
Modulpelatihanp4tkmikrotikModulpelatihanp4tkmikrotik
Modulpelatihanp4tkmikrotik
 
Manualmikrotik
ManualmikrotikManualmikrotik
Manualmikrotik
 
Tutorial mikrotik-2
Tutorial mikrotik-2Tutorial mikrotik-2
Tutorial mikrotik-2
 
Vbtutorial
VbtutorialVbtutorial
Vbtutorial
 
Practicalfileofvb workshop
Practicalfileofvb workshopPracticalfileofvb workshop
Practicalfileofvb workshop
 
Ebookrentalfilm
EbookrentalfilmEbookrentalfilm
Ebookrentalfilm
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 

Visual Basic Programming Examples

  • 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