30-09-16, 01:18 AM
هل يمكن فحص الوقت و التاريخ مثلآ عندى فورم فيها 3 Label الاولة تحصل على الوقت و التريغ من هذا الكود
اما الثانية فيتم كتابة الوقت و التريخ
ايد ان اعرف اذا كان Label1 اكبر من Label2
مشكلة هذا الكود انه لا يفرق بين PM و AM هل من حل ؟
كود :
Public Shared Function GetNistTime() As DateTime
Dim dateTime As DateTime = DateTime.MinValue
Dim request As HttpWebRequest = DirectCast(WebRequest.Create("http://nist.time.gov/actualtime.cgi?lzbc=siqm9b"), HttpWebRequest)
request.Method = "GET"
request.Accept = "text/html, application/xhtml+xml, */*"
request.UserAgent = "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)"
request.ContentType = "application/x-www-form-urlencoded"
request.CachePolicy = New RequestCachePolicy(RequestCacheLevel.NoCacheNoStore)
'No caching
Dim response As HttpWebResponse = DirectCast(request.GetResponse(), HttpWebResponse)
If response.StatusCode = HttpStatusCode.OK Then
Dim stream As New StreamReader(response.GetResponseStream())
Dim html As String = stream.ReadToEnd()
'<timestamp time=\"1395772696469995\" delay=\"1395772696469995\"/>
Dim time As String = Regex.Match(html, "(?<=\btime="")[^""]*").Value
Dim milliseconds As Double = Convert.ToInt64(time) / 1000.0
dateTime = New DateTime(1970, 1, 1).AddMilliseconds(milliseconds).ToLocalTime()
End If
Return dateTime
End Function
اما الثانية فيتم كتابة الوقت و التريخ
كود :
Label2.Text = "9/29/2016 11:20:20 AM"
ايد ان اعرف اذا كان Label1 اكبر من Label2
كود :
If Label1.Text > Label2.Text Then
Label3.Text = "Time Out"
Else
Label3.Text = "Time Running"
End If
مشكلة هذا الكود انه لا يفرق بين PM و AM هل من حل ؟