E se in questa riga
JSys.wSecond = Second(datDate) - 1
i secondi sono a 0, viene settato -1 ...?
da errore e si ripete l'operazione
... e' poco professionale lo so
devo correggerlo
Facci sapere qualcosa di piu' di dataoggi e di datDate ...
allora dataoggi ,viene preso da un server
togliendo il codice non necessario
codice:
Private Sub Inet_StateChanged(ByVal State As Integer)
On Error GoTo errh
Select Case State
Case 12
Dim data
data = Inet.GetHeader("Date")
dataoggi = InternetTimeToVbLocalTime(data)
lblDat = Format(InternetTimeToVbLocalTime(data), " dd / mm / yyyy ")
t_giorni = Date - InternetTimeToVbLocalTime(data)
End Select
Exit Sub
errh:
lblDat = Format(Now, " dd / mm / yyyy ")
dataoggi = now
lblPing = "Errore"
End Sub
la funzione InternetTimeToVbLocalTime
e' standart trovata su un sito ...
Comunque , dovrebbe essere corretto perche'
lblDat = Format(InternetTimeToVbLocalTime(data), " dd / mm / yyyy ")
e' corretto , la data viene data in gg/mm/aaaa
e su lblping non c'e' scritto errore
mentre dat date
viene dall' evento Winsock1_DataArriva
codice:
Winsock1.GetData strData, vbString 'get string from server
datDate = FormatDateTime1(strData) 'go format the new string
la funzione e' stata presa sempre da un altro programma ( open source )
codice:
Private Function FormatDateTime1(ByRef NetTime As String) As Date 'format the string received from time server
Dim strDate As String
Dim strTime As String
'Received string example
'JJJJJ YR-MO-DA HH:MM:SS TT L H msADV UTC(NIST) OTM
'52587 02-11-12 22:05:25 00 0 0 636.1 UTC(NIST) *
'Extract the Date from the received string
strDate = Mid$(NetTime, 11, 5) & "-" & Mid$(NetTime, 8, 2)
'Extract the time from the received string
strTime = Mid$(NetTime, 17, 8)
'Check that extracts are suitable date and time - then convert using CDate
If IsDate(strDate) And IsDate(strTime) Then
FormatDateTime1 = CDate(strDate & " " & strTime)
'Extract the downloaded millisec time offset 'this is the transmission line time delay the server calculated and offset the time by
msAdj = Val(Mid$(NetTime, 33, 3) + Mid$(NetTime, 37, 1))
'Server health is bad, server actually reports it's own condition, do not set if bad
If Mid$(NetTime, 31, 1) <> "0" Then 'is servers' health bad?, then do not set
SetIt = 0 'do not set time
MsgBox "Il server riporta che l'orario al momento potrebbe essere impreciso" & vbCrLf & _
"di conseguenza l'orario non e' stato aggiornato" & vbCrLf & vbCrLf & "Si consiglia di riprovare piu' tardi o contattare il fornitore del programma"
Unload Me
End If
Else
'Date / time format is wrong
SetIt = 0 'do not set time
MsgBox "La risposta del server ha causato un errore di sistema" & vbCrLf & _
"di conseguenza l'orario non e' stato aggiornato" & vbCrLf & vbCrLf & "Si consiglia di riprovare piu' tardi o contattare il fornitore del programma"
Unload Me
End If
End Function
come vedete questo errore (secondo me ) non ha senso di esistere ( sempre ammesso che esista , credo sulla parola del mio 'cliente')
qualcuno piu' esperto di me che mi smentisce???