Dim h1, h2, h3, newH As Long
Dim m1, m2, m3, newM As Long
Dim AllMin As Long
h1 = 10
h2 = 12
h3 = 4556
m1 = 32
m2 = 45
m3 = 54
AllMin = (h1 + h2 + h3) * 60 + m1 + m2 + m3
newH = Int(AllMin / 60)
newM = AllMin Mod 60
Debug.Print newH, newM
Gogic писал(а):
- Код: Выделить всё
Dim h1, h2, h3, newH As Long
Dim m1, m2, m3, newM As Long
Dim h1 As Long, h2 As Long, h3 As Long, newH As Long
Dim m1 As Long, m2 As Long, m3 As Long, newM As Long
Option Explicit
Function FullTime(ParamArray arrTime()) As String
Dim Hours As Long
Dim Minutes As Long
Dim Count As Long
For Count = LBound(arrTime) To UBound(arrTime)
Hours = Hours + Val(Mid(arrTime(Count), 1, InStr(arrTime(Count), ":") - 1))
Minutes = Minutes + Val(Mid(arrTime(Count), InStr(arrTime(Count), ":") + 1))
Next Count
Hours = Hours + Minutes \ 60
Minutes = Minutes Mod 60
FullTime = Hours & ":" & Minutes
End Function
Private Sub Command1_Click()
MsgBox FullTime("21:3", "21:54", "1:23", "5:26")
End Sub
MsgBox FullTime("21:3", "21:54", "1:23", "5:26")
Option Explicit
Function FullTime(ParamArray arrTime()) As String
Dim Hours As Long
Dim Minutes As Long
Dim Count As Long
For Count = LBound(arrTime) To UBound(arrTime)
Hours = Hours + Val(Mid(arrTime(Count), 1, InStr(arrTime(Count), ":") - 1))
Minutes = Minutes + Val(Mid(arrTime(Count), InStr(arrTime(Count), ":") + 1))
Next Count
Hours = Hours + Minutes \ 60
Minutes = Minutes Mod 60
FullTime = Hours & ":" & Minutes
End Function
Private Sub Command1_Click()
Dim A, B, C, D, E, F, G As String
Dim nVar As Integer
Badtime:
A = MaskEdBox1
If IsDate(MaskEdBox1) = False Then
MsgBox "Íåïðàâèëüíûå äàííûå" & vbCr & " â ïîëå âûëåò 1 "
MaskEdBox1 = "00:00"
Exit Sub
GoTo Badtime:
Else
End If
B = MaskEdBox2
If IsDate(MaskEdBox2) = False Then
MsgBox "Íåïðàâèëüíûå äàííûå" & vbCr & " â ïîëå âûëåò 2 "
MaskEdBox2 = "00:00"
Exit Sub
GoTo Badtime:
Else
End If
C = MaskEdBox3
If IsDate(MaskEdBox3) = False Then
MsgBox "Íåïðàâèëüíûå äàííûå" & vbCr & " â ïîëå âûëåò 3 "
MaskEdBox3 = "00:00"
Exit Sub
GoTo Badtime:
Else
End If
D = MaskEdBox4
If IsDate(MaskEdBox4) = False Then
MsgBox "Íåïðàâèëüíûå äàííûå" & vbCr & " â ïîëå âûëåò 4 "
MaskEdBox4 = "00:00"
Exit Sub
GoTo Badtime:
Else
End If
E = FullTime(A, B, C, D)
Label1.Caption = E
F = Label2.Caption
G = FullTime(E, F)
MsgBox "Ïðîâåðü ââåä¸ííûå äàííûå" & vbCr & A & vbCr & B & vbCr & C & vbCr & D & vbCr & E & " Íàðàáîòêà çà äåíü" & vbCr & G & " Îáùàÿ íàðàáîòêà"
Label2.Caption = G
End Sub
Sub Vihod()
Dim Otvet as long
Otvet = MsgBox ("Хотите ли выйти из программы?", vbOKCancel + vbExclamation, "Выход") 'Где vbOkCancel - Кнопки, vbExclamation - тип сообщения(критическое, уведомление и т.д) и Выход - Заголовок MsgBox'a
'Далее
If Otvet = vbOk then
end ' Если нажата клавиша ок, то....конец программы
else ' В других случаях(то есть, если нажата кнопка отмены [Cancel])
Exit Sub ' Заканчиваем процедуру(Выход) то есть ничего не происходит
End If
End Sub
Сейчас этот форум просматривают: SemrushBot, Yandex-бот и гости: 107