الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

إيجاد الفرق بين الوقتين(طرح وقت من وقت)

مغلق
بدأه مجرد مسلم في 22 أكتوبر 2007 · 0 رد · 505 مشاهدة · في لغة Ms Visual Basic 6 وما قبلها من إصدارات
مشاركة: واتساب X فيسبوك تيليجرام
#1

هذا برنامج يقوم بإيجاد الفرق بين وقتين

الشرح:

اكتب في text2 الساعة 12:30واكتب في text1 الساعة10:00 وأنفر فوق الزر(الفرق)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

اكتب هذا التعريف في GENERAL

Dim timediff As String

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Private Sub Command1_Click() اكتب هذا الكود في الزر الفرق

Dim bTest As Boolean

Dim dteBegin As Date

Dim dteEnd As Date

Dim str As String

Dim str2 As String

'Change TextBox Names to Reflect YOUR TextBox!

str = UCase(Text1.Text) 'Begin TIME TextBox

str2 = UCase(Text2.Text) 'End Time TextBox

If Not IsDate(str) Or Not IsDate(str2) Then

MsgBox "Begin AND END TIMES MUST BE VALID TIME: HH:MM AM or PM"

Exit Sub

Else

dteBegin = CDate(str)

dteEnd = CDate(str2)

bTest = GetDateDiff(dteBegin, dteEnd)

If bTest Then ' Check for Success If Successfule, You Can use

' The variable TimeDiff as your "Date" to put into Sybase!

'Replace MsgBox Code with Database insert and you should have it!

MsgBox timediff

End If

End If

End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

قم بكتابة هذه الدالة

Function GetDateDiff(DateBegin As Date, DateEnd As Date) As Boolean

On Error GoTo ErrorHandler

'

Dim str As String

Dim str2 As String

Dim NumHours As Long

Dim NumDays As Long

Dim NumMinutes As Long

Dim TimeLeft As Long

' END DECLARATIONS--------------------------------------------------------------

TimeLeft = DateDiff("n", DateBegin, DateEnd) ' Mumber of MINUTES Between the Two Dates

If TimeLeft > 60 Then

NumHours = TimeLeft \ 60

TimeLeft = TimeLeft Mod 60

Else

NumHours = 0

End If

NumMinutes = TimeLeft

If NumHours < 10 Then

sHours = "0" & CStr(NumHours)

Else

sHours = CStr(NumHours)

End If

If NumMinutes < 10 Then

sMinutes = "0" & CStr(NumMinutes)

Else

sMinutes = CStr(NumMinutes)

End If

'NOW WE REASSEMBLE

strDateTime = sHours & ":" & sMinutes

timediff = CDate(strDateTime)

GetDateDiff = True

ExitProc:

Exit Function

ErrorHandler:

GetDateDiff = False

Select Case Err

Case Else

MsgBox "Error #" & Err & ": " & Error & " in Form1.GetDateDiff"

Resume ExitProc

End Select

Resume ' For Debugging ONLY!

End Function

_______________.rar

نحن لن نستسلم ننتصر أونموت

هذا الموضوع مغلق.

مواضيع مشابهة