日期:2014-05-17 浏览次数:21331 次
Imports System.Text.RegularExpressions
Public Class Form1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
Label1.Text = (String.Format("{1}到{2} : {3}{0}{4}到{5} : {6}{0}{7}到{8} : {9}{0}{10}到{11} : {12}", vbCrLf,
"00:01", "00:34", Demo("00:01", "00:34"),
"01:01", "00:34", Demo("01:01", "00:34"),
"00:34", "00:33", Demo("00:34", "00:33"),
"11:34", "00:33", Demo("11:34", "00:33")
))
End Sub
Private Function Demo(time1 As String, time2 As String) As String
Dim m1 As Match = Regex.Match(time1, "(?<hour>[\d]{1,2})\:(?<minute>[\d]{1,2})", RegexOptions.IgnoreCase Or RegexOptions.ExplicitCapture)
If m1.Success Then
Dim hour1, minute1 As Integer
hour1 = Integer.Parse(m1.Groups("hour").Value)
minute1 = Integer.Parse(m1.Groups("minute").Value)
m1 = Regex.Match(time2, "(?<hour>[\d]{1,2})\:(?<minute>[\d]{1,2})", RegexOptions.IgnoreCase Or RegexOptions.ExplicitCapture)
&nb