Then create a function and reuse at will ? It could give something such as
(checking code left out) :
Shared Function ToTimeSpan(ByVal s As String, Optional ByVal sep As Char
= ":"c) As TimeSpan
Dim v() As String
v = s.Split(sep)
Dim t As New TimeSpan(CInt(v(0)), CInt(v(1)), 0)
Return t
End Function
Shared Sub Main()
MsgBox(ToTimeSpan("47:26").ToString)
MsgBox(ToTimeSpan("3.30", "."c).ToString)
End Sub
--
Patrice
"Charles Law" <bl***@nowhere.coma écrit dans le message de groupe de
discussion :
e4**************@TK2MSFTNGP03.phx.gbl...
I have a 'timespan' which is specified in an unusual way. For example, to
specify 47 hours and 26 minutes, the timepsan is specified as
47:26
If I use Timespen.TryParse on this then, of course, it fails. Can anyone
think of a neat way to decode timespans specified in this way? I also have
timespans specified as
3.30
which would mean 3hrs and 30 minutes.
I realise that I could split the values and format my own timespan, but I
am wondering if there is a one-liner built-in.
TIA
Charles