Jump to content

Change in Time equation in C#


Recommended Posts

I made an application in AutoIT that calculates change in time. Here is the code:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region
$Form1 = GUICreate("Change In Time", 401, 123, 192, 124)
$Input1 = GUICtrlCreateInput("", 16, 16, 41, 21)
$Input2 = GUICtrlCreateInput("", 16, 48, 41, 21)
$Input3 = GUICtrlCreateInput("", 144, 16, 41, 21)
$Input4 = GUICtrlCreateInput("", 144, 48, 41, 21)
$Label1 = GUICtrlCreateLabel("Hours", 64, 18, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("Minutes", 64, 50, 58, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("Hours", 192, 18, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("Minutes", 192, 50, 58, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("Calculate", 168, 88, 75, 25)
$Group1 = GUICtrlCreateGroup("Start", 8, 0, 121, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Group2 = GUICtrlCreateGroup("End", 136, 0, 121, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
$Input5 = GUICtrlCreateInput("", 280, 16, 41, 21)
$Input6 = GUICtrlCreateInput("", 280, 48, 41, 21)
$Label5 = GUICtrlCreateLabel("Hours", 328, 18, 40, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label6 = GUICtrlCreateLabel("Minutes", 328, 50, 58, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Group3 = GUICtrlCreateGroup("Output", 272, 0, 121, 81)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $hourread2 = GUICtrlRead($Input3)
            $hourread1 = GUICtrlRead($Input1)
            $minutesread2 = GUICtrlRead($Input4)
            $minutesread1 = GUICtrlRead($Input2)
            $finalhours = $hourread2 - $hourread1
            If $minutesread1>$minutesread2 Then
                $finalhours -=1
                $minutesread2 +=60
            EndIf
            $minutesfinal = $minutesread2 - $minutesread1
            GUICtrlSetData($Input5, $finalhours)
            GUICtrlSetData($Input6, $minutesfinal)
    EndSwitch
WEnd

I am trying to do the same thing in C Sharp, can anybody help me with this?

Link to comment
Share on other sites

Well I want to be able to display hours and minutes, if I convert to minutes, I would have to find some way of converting back to hours and minutes. Normally you would do this by dividing and finding the remainder. However I am not aware of any script/program that can do that, and if they can, how?

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...