Visualizzazione dei risultati da 1 a 2 su 2

Discussione: Gestione della data

  1. #1
    Utente di HTML.it
    Registrato dal
    Oct 2005
    Messaggi
    1

    Gestione della data

    Ciao a tutti, tengo a precisare che sono un novelo del c#
    vorrei creare un programmino semplice che clikkando su un tasto mi cambia la data del sistema operativo e quando ne clikko un'altro me la ripristina..

    come posso fare per cambiarla?

    ho provato a fare così ma non funziona :


    string time;
    string newdate="20/10/2005 0.00.00";
    time=System.DateTime.Today.Date.ToString(newdate);


    Grazie a tutti per l'aiuto!!!

    CiAo GianKa

  2. #2
    Utente di HTML.it L'avatar di pietro09
    Registrato dal
    Jan 2002
    Messaggi
    10,116
    è in basic. Prova a tradurlo in c#

    codice:
        Private lpSystemTimeOLD As SYSTEMTIME
    
        Declare Function SetLocalTime% Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)
        Declare Sub GetLocalTime Lib "kernel32" (ByRef lpSystemTime As SYSTEMTIME)
    
        Structure SYSTEMTIME
            Dim wYear As Short
            Dim wMonth As Short
            Dim wDayOfWeek As Short
            Dim wDay As Short
            Dim wHour As Short
            Dim wMinute As Short
            Dim wSecond As Short
            Dim wMilliseconds As Short
        End Structure
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            'imposta la data al 28/2/1999
    
            GetLocalTime(lpSystemTimeOLD)
    
            Dim lpSystemTime As SYSTEMTIME
            With lpSystemTime
                .wYear = 1999
                .wMonth = 2
                .wDay = 28
                .wDayOfWeek = lpSystemTimeOLD.wDayOfWeek
                .wHour = lpSystemTimeOLD.wHour
                .wMinute = lpSystemTimeOLD.wMinute
                .wSecond = lpSystemTimeOLD.wSecond
                .wMilliseconds = lpSystemTimeOLD.wMilliseconds
            End With
    
            Dim er% = SetLocalTime(lpSystemTime)
            If er = 0 Then MsgBox("Errore")
    
    
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            'ripristina la data
    
            Dim lpSystemTime As SYSTEMTIME
            GetLocalTime(lpSystemTime)
    
            With lpSystemTime
                .wYear = lpSystemTimeOLD.wYear
                .wMonth = lpSystemTimeOLD.wMonth
                .wDay = lpSystemTimeOLD.wDay
                .wDayOfWeek = lpSystemTimeOLD.wDayOfWeek
            End With
    
            Dim er% = SetLocalTime(lpSystemTime)
            If er = 0 Then MsgBox("Errore")
    
    
        End Sub
    Naturalmente è una finestra windows e non una pagina asp.net
    Pietro

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2026 vBulletin Solutions, Inc. All rights reserved.