Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27514

use date.tryparse for multiple time formats

$
0
0
Hello,

I have a piece of code that checks if the userinput is a specific time format.

Code:

Dim dt1 As DateTime = Date.ParseExact(Me.txtBeginTijd.Text, "HH:mm:ss", Globalization.DateTimeFormatInfo.InvariantInfo)
      Dim ts1 As TimeSpan = dt1.TimeOfDay

The code works fine when I enter a time in the specific format.
But I also would like to be able to enter the format "HH:mm".

How should I alter my code so this is possible?

Thaqnks in advance!!!

Viewing all articles
Browse latest Browse all 27514

Trending Articles