qui mando tutto il codice che in pratica è tutto tuo
a parte qualcosa e funziona bene se non fosse che non
sempre si apre subito il sito allora ho aggiunto la
riga
poi ricavo ora, minuti e secondi in n1,n2,n3
qui tutto il codice
codice:
Imports System
----------------------
Public Structure SYSTEMTIME
Public wYear As UInt16
Public wMonth As UInt16
Public wDayOfWeek As UInt16
Public wDay As UInt16
Public wHour As UInt16
Public wMinute As UInt16
Public wSecond As UInt16
Public wMilliseconds As UInt16
End Structure
-------------------------
Public Class Form1
Declare Function GetSystemTime Lib "Kernel32.dll" (ByRef lpSystemTime As SYSTEMTIME) As UInt32
Declare Function SetSystemTime Lib "Kernel32.dll" (ByRef lpSystemTime As SYSTEMTIME) As UInt32
Dim n1, n2, n3 As Integer
--------------------------------------------
Public Sub GetTime()
' Call the native GetSystemTime method
' with the defined structure.
Dim st As New SYSTEMTIME
GetSystemTime(st)
' Show the current time.
MessageBox.Show("Current Time: " & st.wHour.ToString() _
& ":" & st.wMinute.ToString())
End Sub
----------------------------------------------
Public Sub SetTime()
' Call the native GetSystemTime method
' with the defined structure.
Dim st As New SYSTEMTIME
GetSystemTime(st)
st.wHour = n1
st.wMinute = n2
st.wSecond = n3
' Set the system clock ahead one hour.
'st.wHour = Convert.ToUInt16(((CInt(st.wHour) + 1)) Mod 24)
SetSystemTime(st)
End Sub
----------------------------------------
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim gs, ns As String
Dim nn, n4 As Integer
Dim sourceString As String
If New System.Net.WebClient().DownloadString("http://tycho.usno.navy.mil/cgi-bin/t...ains("!DOCTYPE") Then
sourceString = New System.Net.WebClient().DownloadString("http://tycho.usno.navy.mil/cgi-bin/timer.pl")
gs = sourceString.Substring(1, 200)
nn = InStrRev(gs, ",")
ns = Mid(gs, (nn + 2), 8)
n1 = Val(Mid(ns, 1, 2))
n2 = Val(Mid(ns, 4, 2))
n3 = Val(Mid(ns, 7, 2))
n4 = n1 + 2
TextBox1.Text = n4.ToString("00") & ":" & n2.ToString("00") & ":" & n3.ToString("00")
SetTime()
End If
End Sub
End Class