Jump to content

Read Date


Nunos
 Share

Go to solution Solved by Nine,

Recommended Posts

GUI()


Func GUI()

    Local $msg
    Local $btnOkay
    Local $btnClose

    $GUI = GUICreate("Record Serial Number", 280, 280) ; will create a dialog box that when displayed is centered

    GUICtrlCreateLabel("Please input the manufacturers name", 15, 25)
    $inpBoxMFRName = GUICtrlCreateInput("Posiflex", 15, 45, 150, 20)

    GUICtrlCreateLabel("Please input the model number", 15, 75)
    $inpBoxModName = GUICtrlCreateInput("", 15, 95, 150, 20)

    GUICtrlCreateLabel("Please input the serial number", 15, 125)
    $inpBoxSerialNumber = GUICtrlCreateInput("", 15, 145, 150, 20)

    GUICtrlCreateLabel("Please input the date of purchase", 15, 175)
    ;$inpBoxDate = GUICtrlCreateInput("mm/dd/yyyy", 15, 195, 150, 20)
    $inpBoxDate = _GUICtrlDTP_Create($GUI, 15, 195, 150, 20)
    _GUICtrlDTP_SetFormat($inpBoxDate, "MM/dd/yyyy") ; the uppercase/lowercase actually matters
    $btnOkay = GUICtrlCreateButton("Okay", 65, 245, 85, 25)
    $btnClose = GUICtrlCreateButton("Close", 165, 245, 85, 25)

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $msg = $btnClose ;This moves the previously backed up version of SN.ini back to where it should be
                FileCopy("C:\IDS\SN.ini", @AppDataDir & "\IDS\SN.ini", 1 + 8)
                ExitLoop
            Case $msg = $btnOkay ;This writes to the ini file the data you enter in the form

                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Computer Name", @ComputerName)
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Manufacturer", GUICtrlRead($inpBoxMFRName))
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Model", GUICtrlRead($inpBoxModName))
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Serial", GUICtrlRead($inpBoxSerialNumber))
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Date", GUICtrlRead($inpBoxDate))


                ExitLoop
        EndSelect
    WEnd

EndFunc   ;==>GUI

I used 

$inpBoxDate = _GUICtrlDTP_Create($GUI, 15, 195, 150, 20)
    _GUICtrlDTP_SetFormat($inpBoxDate, "MM/dd/yyyy") ; the uppercase/lowercase actually matters

to try to format and get a calender for selecting dates but when I try to read it and record it to an ini file I get Date: 0

IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Date", GUICtrlRead($inpBoxDate))

Not sure what I am missing here. 

Link to comment
Share on other sites

  • Solution

Awesome thany you all for helping I appreciate it. I switched it to GUICtrlCreateDate which is now working. 😀

Below is the code incase someone has need of it in the future.

GUI()


Func GUI()

    Local $msg
    Local $btnOkay
    Local $btnClose

    $GUI = GUICreate("Record Serial Number", 280, 280) ; will create a dialog box that when displayed is centered

    GUICtrlCreateLabel("Please input the manufacturers name", 15, 25)
    $inpBoxMFRName = GUICtrlCreateInput("Posiflex", 15, 45, 150, 20)

    GUICtrlCreateLabel("Please input the model number", 15, 75)
    $inpBoxModName = GUICtrlCreateInput("", 15, 95, 150, 20)

    GUICtrlCreateLabel("Please input the serial number", 15, 125)
    $inpBoxSerialNumber = GUICtrlCreateInput("", 15, 145, 150, 20)

    GUICtrlCreateLabel("Please input the date of purchase", 15, 175)
    $inpBoxDate = GUICtrlCreateDate("", 15, 195, 150, 20, $DTS_SHORTDATEFORMAT)
    $btnOkay = GUICtrlCreateButton("Okay", 65, 245, 85, 25)
    $btnClose = GUICtrlCreateButton("Close", 165, 245, 85, 25)

    GUISetState()

    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop

            Case $msg = $btnClose ;This moves the previously backed up version of SN.ini back to where it should be
                FileCopy("C:\IDS\SN.ini", @AppDataDir & "\IDS\SN.ini", 1 + 8)
                ExitLoop
            Case $msg = $btnOkay ;This writes to the ini file the data you enter in the form

                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Computer Name", @ComputerName)
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Manufacturer", GUICtrlRead($inpBoxMFRName))
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Model", GUICtrlRead($inpBoxModName))
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Serial", GUICtrlRead($inpBoxSerialNumber))
                IniWrite(@AppDataDir & "\IDS\SN.ini", "Information", "Date", GUICtrlRead($inpBoxDate))


                ExitLoop
        EndSelect
    WEnd

EndFunc   ;==>GUI

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...