Alguien me puede ayudar con este contador de horas
Publicado por julian (2 intervenciones) el 09/04/2007 05:23:43
'Nota:como puedo hacer que este contador me calcule el valor del tiempo en un texbox en 'dinero
Option Explicit
Private Time As Double
Dim cal As Double
Dim timemin As Double
Private Function CalculateTime(Time As Double) As String
Dim TimeHour As Double
Dim strTimeHour As String
Dim timemin As Double
Dim strTimeMin As String
Dim TimeSec As Byte
Dim strTimeSec As String
Dim CalcTime As String
'Calculate the actual times
TimeHour = Int((Time / 60) / 60)
timemin = Int(Time / 60)
timemin = timemin Mod 60
TimeSec = Int(Time Mod 60)
'Change times to appropriate formats
strTimeMin = timemin
If Len(strTimeMin) = 1 Then
strTimeMin = "0" & strTimeMin
End If
strTimeSec = TimeSec
If Len(strTimeSec) = 1 Then
strTimeSec = "0" & strTimeSec
End If
strTimeHour = TimeHour
If Len(strTimeHour) = 1 Then
strTimeHour = "0" & strTimeHour
End If
'Assign the appropriate values to the label
CalculateTime = strTimeHour & ":" & strTimeMin & ":" & strTimeSec
End Function
Private Sub cmdClear_Click()
Time = 0
Timer1.Enabled = False
lblTime = "00:00:00"
cmdClear.Enabled = False
cmdStop.Enabled = False
End Sub
Private Sub cmdStart_Click()
Timer1.Enabled = True
cmdClear.Enabled = False
cmdStop.Enabled = True
cmdStart.Enabled = False
End Sub
Private Sub cmdStop_Click()
Timer1.Enabled = False
cmdClear.Enabled = True
cmdStart.Enabled = True
cmdStop.Enabled = False
End Sub
Private Sub Form_Load()
lblTime.Caption = "00:00:00"
Time = 0
End Sub
Private Sub Text1_Change()
Text1.Text = Time + calculpresio
End Sub
Private Sub Timer1_Timer()
Time = Time + 1
lblTime.Caption = CalculateTime(Time)
End Sub
Private Function calculpresio() As Double
cal = Text1 + 10
End Function
Private Sub Timer2_Timer()
Text1.Text = Time
End Sub
Option Explicit
Private Time As Double
Dim cal As Double
Dim timemin As Double
Private Function CalculateTime(Time As Double) As String
Dim TimeHour As Double
Dim strTimeHour As String
Dim timemin As Double
Dim strTimeMin As String
Dim TimeSec As Byte
Dim strTimeSec As String
Dim CalcTime As String
'Calculate the actual times
TimeHour = Int((Time / 60) / 60)
timemin = Int(Time / 60)
timemin = timemin Mod 60
TimeSec = Int(Time Mod 60)
'Change times to appropriate formats
strTimeMin = timemin
If Len(strTimeMin) = 1 Then
strTimeMin = "0" & strTimeMin
End If
strTimeSec = TimeSec
If Len(strTimeSec) = 1 Then
strTimeSec = "0" & strTimeSec
End If
strTimeHour = TimeHour
If Len(strTimeHour) = 1 Then
strTimeHour = "0" & strTimeHour
End If
'Assign the appropriate values to the label
CalculateTime = strTimeHour & ":" & strTimeMin & ":" & strTimeSec
End Function
Private Sub cmdClear_Click()
Time = 0
Timer1.Enabled = False
lblTime = "00:00:00"
cmdClear.Enabled = False
cmdStop.Enabled = False
End Sub
Private Sub cmdStart_Click()
Timer1.Enabled = True
cmdClear.Enabled = False
cmdStop.Enabled = True
cmdStart.Enabled = False
End Sub
Private Sub cmdStop_Click()
Timer1.Enabled = False
cmdClear.Enabled = True
cmdStart.Enabled = True
cmdStop.Enabled = False
End Sub
Private Sub Form_Load()
lblTime.Caption = "00:00:00"
Time = 0
End Sub
Private Sub Text1_Change()
Text1.Text = Time + calculpresio
End Sub
Private Sub Timer1_Timer()
Time = Time + 1
lblTime.Caption = CalculateTime(Time)
End Sub
Private Function calculpresio() As Double
cal = Text1 + 10
End Function
Private Sub Timer2_Timer()
Text1.Text = Time
End Sub
Valora esta pregunta


0