• We just launched and are currently in beta. Join us as we build and grow the community.

Split Timer using Visual Basic.Net

jes152003

Crypto Fund Manager
J Rep
0
0
0
Rep
0
J Vouches
0
0
0
Vouches
0
Posts
161
Likes
120
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 200 XP
In this tutorial I’m going to teach you how to create split timer using visual basic.net. To start in this course you need to download first the “Digital stopwatch” which we’re going to use in this tutorial. You can follow this link to download this progam;http://www.sourcecodester.com/tutor.../digital-stopwatch-using-visual-basicnet.html.

Here’s the sample screenshots if you completed this course and it looks like as shown below.

untitled_0.png


This this time you need to add one button for “Split” and one Datagridview. And name the new button as “btnSplit” and the Text is “Split”, and set the Datagridview AutoSizeColumnMode in to “Fill” and Uncheck the “Enable Adding”.

Next let’s start coding. To do this double click the form load and add this code. And it should be looks like as shown below.
  1. Private

    Sub

    Form1_Load(

    ByVal

    sender As

    System.

    Object

    , ByVal

    e As

    System.

    EventArgs

    )

    Handles

    MyBase

    .

    Load

  2. 'it do the initialization
  3. 'add new column for our datagridview
  4. DT.

    Columns

    .

    Add

    (

    "Split Time Record"

    )
  5. 'get the datasource from Datatable named DT
  6. DataGridView1.

    DataSource

    =

    DT
  7. 'set the sort mode of the datagrid into descending order.
  8. DataGridView1.

    Sort

    (

    DataGridView1.

    Columns

    (

    0

    )

    , System.

    ComponentModel

    .

    ListSortDirection

    .

    Descending

    )


  9. a =

    "0"
  10. b =

    "0"
  11. c =

    "0"
  12. d =

    "0"
  13. y =

    "0"
  14. z =

    "0"
  15. u =

    "0"
  16. v =

    "0"

  17. h =

    a +

    b
  18. m =

    c +

    d
  19. s =

    y +

    z
  20. 'display as "00:00:00.00"
  21. txttime.

    Text

    =

    h +

    ":"

    +

    m +

    ":"

    +

    s +

    "."

    +

    u +

    v
  22. End

    Sub

Next set the "Start" button to Disable when the timer is running. To do this just follow this code.

  1. 'start the timer
  2. Timer1.

    Start

    (

    )
  3. 'check if the text of these button is set to continue set by pause button then it set to start
  4. If

    BtnStart.

    Text

    =

    "Start"

    Then
  5. 'disable Start button
  6. BtnStart.

    Enabled

    =

    False
  7. End

    If

Next double click the “Split” button and add this code.


  1. DataGridView1.

    Visible

    =

    True
  2. DT.

    Rows

    .

    Add

    (

    txttime.

    Text

    )

At first it will give you an error because DT is not yet declared. So to avoid this error we need to declare this above below public class together with another declaration of variable.
  1. Dim

    DT As

    New

    DataTable

After this you can now test by running your program. The process would be the user will click the “Start” button and the timer will start running and as you observe the “Start” button will be disabled. Next when the user click the “Split” button the value of the text box will then now display in the datagridview in descending order. And everything will follow based on the choice.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

452,292

323,341

323,350

Top