Split Days and Time
This code enables you to convert or split the input of days, hours, minutes, seconds and milliseconds to assign them on each textbox and determine what was your input but you need to follow the correct format to work the program properly.
Open your Visual Basic .NET Application.
Step 1:
Create a New Project, go to File Menu and navigate to New > Project and put a project name of ConvertDaysTime.
Step 2:
Create the following objects:
1 – Frame (TEXT PROPERTIES: Days and Time)
1 – Button (TEXT PROPERTIES: Convert)
5 – Labels (TEXT PROPERTIES: Days, Hours, Minutes, Seconds, Miliseconds)
6 – Textbox (NAME PROPERTIES: txtConvert, txtDays, txtHours, txtMinutes, txtSeconds, txtMili)
Step 3:
Put this code in your code editor
Final Output
Open your Visual Basic .NET Application.
Step 1:
Create a New Project, go to File Menu and navigate to New > Project and put a project name of ConvertDaysTime.
Step 2:
Create the following objects:
1 – Frame (TEXT PROPERTIES: Days and Time)
1 – Button (TEXT PROPERTIES: Convert)
5 – Labels (TEXT PROPERTIES: Days, Hours, Minutes, Seconds, Miliseconds)
6 – Textbox (NAME PROPERTIES: txtConvert, txtDays, txtHours, txtMinutes, txtSeconds, txtMili)
Step 3:
Put this code in your code editor
Public Class frmConvertDaysPrivate Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.LoadtxtConvert.Text = "4.12:59:06.12" 'You can change the content of this string valueEnd SubPrivate Sub Parse_Days_Time(ByVal TSpan As TimeSpan)'IN USING THE PROPERTIES OF THE TIMESPAN, IT WILL SEPERATE THE DAYS AND TIME'IT DEMONSTRATES THE TimeSpan.Days, TimeSpan.Hours,'TimeSpan.Minutes, TimeSpan.Seconds'AND TimeSpan.MillisecondsTrytxtDays.Text = TSpan.Days.ToStringtxtHours.Text = TSpan.Hours.ToStringtxtMinutes.Text = TSpan.Minutes.ToStringtxtSeconds.Text = TSpan.Seconds.ToStringtxtMili.Text = TSpan.Milliseconds.ToStringCatch ex As ExceptionMsgBox(ex.Message, Me.Text)End TryEnd SubPrivate Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.ClickTryDim TSpan As TimeSpan'CONVERTS THE STRING VALUE INTO TIMESPANTSpan = TimeSpan.Parse(txtConvert.Text)'SET THE VALUE OF THE TIMESPAN'TO THE PARAMETER OF THE SUB PROCEDURE THAT YOU HAVE CREATED.Parse_Days_Time(TSpan)Catch ex As ExceptionMsgBox(Me.Text, ex.Message)End TryEnd SubEnd Class
Final Output
Split Days and Time
Reviewed by code-dev
on
4:11 PM
Rating:
No comments: