SlideShare a Scribd company logo
Stop Watch.
VB.NET
16/7/2019
12:04 AM
SUROJIT PAUL
Program:-1
Sum of Numbers
(Without array)
Label
name-> lblAvg
Button
name-> btnC
Textbox
name-> txtN
Listbox
name-> lstN
Label
name-> lblSum
Be careful when copy/paste this code.
Code Starts Here:
Public Class Form1
'sum of Number Without Array
Dim s, avg, i As Integer
Private Sub btnC_Click(sender As Object, e As EventArgs) Handles btnC.Click
'clear the controls
lstN.Items.Clear()
txtN.Clear()
lblAvg.Text = ""
lblSum.Text = ""
'reset the values
s = avg = i = 0
End Sub
Private Sub txtN_KeyDown(sender As Object, e As KeyEventArgs) Handles txtN.KeyDown
'check if user pressed an 'Enter Key'
If e.KeyCode = Keys.Enter Then
lstN.Items.Add(txtN.Text) 'add the number in listbox
i = i + 1 'only average
s = s + txtN.Text 'use for sum
'show the answar in label
lblSum.Text = s 'sum label
lblAvg.Text = s / i 'average label
txtN.Text = "" 'clear the textbox for next input
End If
End Sub
End Class
Code Ends Here.
Program:-2
Stopwatch (without comment)
(With Lap And Manual Reverse)
You will Need 3 Timer
Label
Name:-lblH
Label
Name:-lblM
Label
Name:-lblS
Textbox
Name:-txtGo
Listbox
Name:-lstLaps
Button
Name:-btnGo
Button
Name:-btnReset
Button
Name:-btnLap
Button
Name:-btnPlayPause
Timer1 interval: 1000
Timer2 interval: 1000
Timer3 interval: 600 it is only used for text blinking
Code Starts Here:
Public Class Form1
Dim ss, mm, hh As Integer
Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click
ResetColor()
ss = 0 : mm = 0 : hh = 0
lblH.Text = "00"
lblM.Text = "00"
lblS.Text = "00"
btnPlayPause.Text = "Start"
Timer1.Enabled = False
End Sub
Private Sub btnPlayPause_Click(sender As Object, e As EventArgs) Handles btnPlayPause.Click
Timer2.Enabled = False
If Timer1.Enabled Then
Timer1.Enabled = False
btnPlayPause.Text = "Resume"
Else
Timer1.Enabled = True
btnPlayPause.Text = "Pause"
End If
End Sub
Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click
ResetColor()
Timer1.Enabled = False
Dim LapValueS As Integer
LapValueS = CInt(txtGo.Text)
mm = LapValueS  60
ss = LapValueS Mod 60
lblS.Text = ss
lblM.Text = mm
Timer2.Enabled = True
End Sub
Private Sub btnLap_Click(sender As Object, e As EventArgs) Handles btnLap.Click
Dim LapT As String
LapT = hh & ":" & mm & ":" & ss
lstLaps.Items.Add(LapT)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
ss = ss + 1
lblS.Text = ss
If ss >= 59 Then
mm = mm + 1
lblM.Text = mm
ss = 0
If mm >= 59 Then
hh = hh + 1
lblH.Text = hh
mm = 0
End If
End If
End Sub
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
ss = ss - 1
If ss < 0 Then
ss = 59
mm = mm - 1
lblM.Text = mm
End If
lblS.Text = ss
If ss = 0 And mm = 0 Then
Timer2.Enabled = False
Timer3.Enabled = True
End If
End Sub
Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick
If lblS.ForeColor <> Color.Black Then
lblH.ForeColor = Color.Black
lblM.ForeColor = Color.Black
lblS.ForeColor = Color.Black
ElseIf lblS.ForeColor = Color.Black Then
lblH.ForeColor = Color.Tomato
lblM.ForeColor = Color.Tomato
lblS.ForeColor = Color.Tomato
End If
End Sub
Private Sub ResetColor()
lblH.ForeColor = Color.DarkRed
lblM.ForeColor = Color.ForestGreen
lblS.ForeColor = Color.RoyalBlue
Timer3.Enabled = False
End Sub
End Class
Code Ends Here.
Stop watch and array

More Related Content

Similar to Stop watch and array

Lampiran source code
Lampiran source codeLampiran source code
Lampiran source codeancunk
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
Prof. Dr. K. Adisesha
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
Marwane Lamouri
 
Updated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptxUpdated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptx
SarveshDeodhar
 
Vb Project ขั้นเทพ
Vb Project ขั้นเทพVb Project ขั้นเทพ
Vb Project ขั้นเทพ
Sinchai Lanon
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informatica
miguel camelo
 
I keep getting a BC30389 'System.Currency' is not accessible in this context ...
I keep getting a BC30389 'System.Currency' is not accessible in this context ...I keep getting a BC30389 'System.Currency' is not accessible in this context ...
I keep getting a BC30389 'System.Currency' is not accessible in this context ...
hwbloom115
 
Vb.net programs
Vb.net programsVb.net programs
VisualBasicExample
VisualBasicExampleVisualBasicExample
VisualBasicExampleBo Dake
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
corbing9ttj
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
corbing9ttj
 
I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...
hwbloom115
 
Puerto serialarduino
Puerto serialarduinoPuerto serialarduino
Puerto serialarduino
zadkiel_123
 
Laboratory activity 3 b1
Laboratory activity 3 b1Laboratory activity 3 b1
Laboratory activity 3 b1Jomel Penalba
 

Similar to Stop watch and array (20)

Docimp
DocimpDocimp
Docimp
 
Lampiran source code
Lampiran source codeLampiran source code
Lampiran source code
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
 
Updated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptxUpdated Visual Basic 6 for beginners.pptx
Updated Visual Basic 6 for beginners.pptx
 
Colegio municipal
Colegio municipalColegio municipal
Colegio municipal
 
Vb Project ขั้นเทพ
Vb Project ขั้นเทพVb Project ขั้นเทพ
Vb Project ขั้นเทพ
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informatica
 
Vb file
Vb fileVb file
Vb file
 
I keep getting a BC30389 'System.Currency' is not accessible in this context ...
I keep getting a BC30389 'System.Currency' is not accessible in this context ...I keep getting a BC30389 'System.Currency' is not accessible in this context ...
I keep getting a BC30389 'System.Currency' is not accessible in this context ...
 
Vb.net programs
Vb.net programsVb.net programs
Vb.net programs
 
Listing program
Listing programListing program
Listing program
 
VisualBasicExample
VisualBasicExampleVisualBasicExample
VisualBasicExample
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
 
I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...I can't get my code below to work with Option Strict On due to this part of t...
I can't get my code below to work with Option Strict On due to this part of t...
 
Puerto serialarduino
Puerto serialarduinoPuerto serialarduino
Puerto serialarduino
 
UtilityCostCalcCode
UtilityCostCalcCodeUtilityCostCalcCode
UtilityCostCalcCode
 
Laboratory activity 3 b1
Laboratory activity 3 b1Laboratory activity 3 b1
Laboratory activity 3 b1
 
Richtextbox
RichtextboxRichtextbox
Richtextbox
 

Recently uploaded

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
ShivajiThube2
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
DhatriParmar
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 

Recently uploaded (20)

A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
JEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questionsJEE1_This_section_contains_FOUR_ questions
JEE1_This_section_contains_FOUR_ questions
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
The Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptxThe Diamond Necklace by Guy De Maupassant.pptx
The Diamond Necklace by Guy De Maupassant.pptx
 
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptxChapter 4 - Islamic Financial Institutions in Malaysia.pptx
Chapter 4 - Islamic Financial Institutions in Malaysia.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 

Stop watch and array

  • 3. Label name-> lblAvg Button name-> btnC Textbox name-> txtN Listbox name-> lstN Label name-> lblSum Be careful when copy/paste this code.
  • 4. Code Starts Here: Public Class Form1 'sum of Number Without Array Dim s, avg, i As Integer Private Sub btnC_Click(sender As Object, e As EventArgs) Handles btnC.Click 'clear the controls lstN.Items.Clear() txtN.Clear() lblAvg.Text = "" lblSum.Text = "" 'reset the values s = avg = i = 0 End Sub Private Sub txtN_KeyDown(sender As Object, e As KeyEventArgs) Handles txtN.KeyDown 'check if user pressed an 'Enter Key' If e.KeyCode = Keys.Enter Then lstN.Items.Add(txtN.Text) 'add the number in listbox i = i + 1 'only average s = s + txtN.Text 'use for sum 'show the answar in label lblSum.Text = s 'sum label lblAvg.Text = s / i 'average label txtN.Text = "" 'clear the textbox for next input End If End Sub End Class Code Ends Here.
  • 5. Program:-2 Stopwatch (without comment) (With Lap And Manual Reverse) You will Need 3 Timer
  • 7. Timer1 interval: 1000 Timer2 interval: 1000 Timer3 interval: 600 it is only used for text blinking
  • 8. Code Starts Here: Public Class Form1 Dim ss, mm, hh As Integer Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click ResetColor() ss = 0 : mm = 0 : hh = 0 lblH.Text = "00" lblM.Text = "00" lblS.Text = "00" btnPlayPause.Text = "Start" Timer1.Enabled = False End Sub Private Sub btnPlayPause_Click(sender As Object, e As EventArgs) Handles btnPlayPause.Click Timer2.Enabled = False If Timer1.Enabled Then Timer1.Enabled = False btnPlayPause.Text = "Resume" Else Timer1.Enabled = True btnPlayPause.Text = "Pause" End If End Sub Private Sub btnGo_Click(sender As Object, e As EventArgs) Handles btnGo.Click ResetColor() Timer1.Enabled = False Dim LapValueS As Integer LapValueS = CInt(txtGo.Text) mm = LapValueS 60 ss = LapValueS Mod 60 lblS.Text = ss lblM.Text = mm Timer2.Enabled = True End Sub Private Sub btnLap_Click(sender As Object, e As EventArgs) Handles btnLap.Click Dim LapT As String LapT = hh & ":" & mm & ":" & ss lstLaps.Items.Add(LapT) End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick ss = ss + 1 lblS.Text = ss If ss >= 59 Then mm = mm + 1 lblM.Text = mm ss = 0
  • 9. If mm >= 59 Then hh = hh + 1 lblH.Text = hh mm = 0 End If End If End Sub Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick ss = ss - 1 If ss < 0 Then ss = 59 mm = mm - 1 lblM.Text = mm End If lblS.Text = ss If ss = 0 And mm = 0 Then Timer2.Enabled = False Timer3.Enabled = True End If End Sub Private Sub Timer3_Tick(sender As Object, e As EventArgs) Handles Timer3.Tick If lblS.ForeColor <> Color.Black Then lblH.ForeColor = Color.Black lblM.ForeColor = Color.Black lblS.ForeColor = Color.Black ElseIf lblS.ForeColor = Color.Black Then lblH.ForeColor = Color.Tomato lblM.ForeColor = Color.Tomato lblS.ForeColor = Color.Tomato End If End Sub Private Sub ResetColor() lblH.ForeColor = Color.DarkRed lblM.ForeColor = Color.ForestGreen lblS.ForeColor = Color.RoyalBlue Timer3.Enabled = False End Sub End Class Code Ends Here.