' Collection of code snippets by Arne Vajhøj ' posted to eksperten.dk, usenet and other places (2002-now) Imports System Imports Microsoft.VisualBasic Module Main Sub Main() Dim tim, min, sek As Byte ' original Dim strDelLine As String = "12:34:56" If strDelLine.Chars(0) = "0" Then tim = CByte(Mid(strDelLine, 2, 1)) Else tim = CByte(Mid(strDelLine, 1, 2)) End If If strDelLine.Chars(3) = "0" Then min = CByte(Mid(strDelLine, 5, 1)) Else min = CByte(Mid(strDelLine, 4, 2)) End If If strDelLine.Chars(6) = "0" Then sek = CByte(Mid(strDelLine, 8, 1)) Else sek = CByte(Mid(strDelLine, 7, 2)) End If Console.WriteLine(tim & " " & min & " " & sek) ' dot netsk If strDelLine.Chars(0) = "0" Then tim = Byte.Parse(strDelLine.Substring(1, 1)) Else tim = Byte.Parse(strDelLine.Substring(0, 2)) End If If strDelLine.Chars(3) = "0" Then min = Byte.Parse(strDelLine.Substring(4, 1)) Else min = Byte.Parse(strDelLine.Substring(3, 2)) End If If strDelLine.Chars(6) = "0" Then sek = Byte.Parse(strDelLine.Substring(7, 1)) Else sek = Byte.Parse(strDelLine.Substring(6, 2)) End If Console.WriteLine(tim & " " & min & " " & sek) ' den smarte måde Dim dt As DateTime = DateTime.Parse(strDelLine) tim = dt.Hour min = dt.Minute sek = dt.Second Console.WriteLine(tim & " " & min & " " & sek) End Sub End Module