SlideShare a Scribd company logo
1 of 10
Download to read offline
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
 
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.pptxSarveshDeodhar
 
Vb Project ขั้นเทพ
Vb Project ขั้นเทพVb Project ขั้นเทพ
Vb Project ขั้นเทพSinchai Lanon
 
Ensayo Convergencia Informatica
Ensayo Convergencia InformaticaEnsayo Convergencia Informatica
Ensayo Convergencia Informaticamiguel 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
 
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.docxcorbing9ttj
 
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.docxcorbing9ttj
 
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 serialarduinozadkiel_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

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docxPoojaSen20
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
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
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Shubhangi Sonawane
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 

Recently uploaded (20)

PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
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 ...
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 

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.