Click here to Skip to main content
16,006,535 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Currency Converter Pin
J4amieC23-Mar-05 11:51
J4amieC23-Mar-05 11:51 
GeneralRe: Currency Converter Pin
Dave Kreskowiak23-Mar-05 12:19
mveDave Kreskowiak23-Mar-05 12:19 
GeneralRe: Currency Converter Pin
Christian Graus23-Mar-05 17:53
protectorChristian Graus23-Mar-05 17:53 
GeneralMoving itmes in a windows application Pin
Mr Dabbah23-Mar-05 1:47
Mr Dabbah23-Mar-05 1:47 
GeneralRe: Moving itmes in a windows application Pin
Anonymous23-Mar-05 18:41
Anonymous23-Mar-05 18:41 
GeneralTimeSpan Average Pin
Sumit Domyan23-Mar-05 0:58
Sumit Domyan23-Mar-05 0:58 
GeneralRe: TimeSpan Average Pin
J4amieC23-Mar-05 5:53
J4amieC23-Mar-05 5:53 
GeneralRe: TimeSpan Average Pin
Sumit Domyan23-Mar-05 17:54
Sumit Domyan23-Mar-05 17:54 
Its not like that dear we cannot divide a time span directly. I have written a function for getting timespan average now. You just need to pass a timespan value which will be the sum of two values.

Friend Function AverageTimeSpan(ByVal time_span As TimeSpan) As TimeSpan
Dim temp_op As Int32
Dim seconds As Int32
Dim milli_seconds As Int32


'1 Day = 86400 Seconds
'1 Hour = 3600 Seconds
'1 Minute = 60 Seconds
seconds = 0
If time_span.Days > 0 Then
temp_op = time_span.Days
seconds += temp_op * 86400
End If


If time_span.Hours > 0 Then
temp_op = time_span.Hours
seconds += temp_op * 3600
End If

If time_span.Minutes > 0 Then
temp_op = time_span.Minutes
seconds += temp_op * 60
End If

If time_span.Seconds > 0 Then
temp_op = time_span.Seconds
seconds += temp_op
End If

milli_seconds = 0
If seconds > 0 Then
If seconds Mod 2 = 0 Then
seconds = CInt(seconds / 2)
Else
milli_seconds = 500
seconds -= 1
seconds = CInt(seconds / 2)
End If
End If

If time_span.Milliseconds > 0 Then
temp_op = time_span.Milliseconds
temp_op = CInt(temp_op / 2)
milli_seconds += temp_op
End If

AverageTimeSpan = CalculateTimeSpan(seconds, milli_seconds)
End Function

Friend Function CalculateTimeSpan(ByVal seconds As Integer, ByVal milliseconds As Int32) As TimeSpan
Dim days As Int32
Dim hours As Int32
Dim minutes As Int32
Dim temp_time_span As TimeSpan

'1 Day = 86400 Seconds
'1 Hour = 3600 Seconds
'1 Minute = 60 Seconds
days = CInt(Math.Floor(seconds / 86400))
seconds = seconds Mod 86400
If seconds > 0 Then
hours = CInt(Math.Floor(seconds / 3600))
seconds = seconds Mod 3600
Else
hours = 0
End If

If seconds > 0 Then
minutes = CInt(Math.Floor(seconds / 60))
seconds = seconds Mod 60
Else
minutes = 0
seconds = 0
End If

temp_time_span = New TimeSpan(days, hours, minutes, seconds, milliseconds)
CalculateTimeSpan = temp_time_span
End Function



Thanks

Sumit Domyan
GeneralRe: TimeSpan Average Pin
Robert Rohde23-Mar-05 20:03
Robert Rohde23-Mar-05 20:03 
GeneralRe: TimeSpan Average Pin
Sumit Domyan23-Mar-05 22:05
Sumit Domyan23-Mar-05 22:05 
GeneralRe: TimeSpan Average Pin
J4amieC23-Mar-05 23:27
J4amieC23-Mar-05 23:27 
GeneralExcel & VBA Userform Pin
saorscha22-Mar-05 21:07
saorscha22-Mar-05 21:07 
GeneralXML Upload to SQL Server Pin
cormac12322-Mar-05 18:57
cormac12322-Mar-05 18:57 
GeneralRe: XML Upload to SQL Server Pin
Dave Kreskowiak23-Mar-05 0:31
mveDave Kreskowiak23-Mar-05 0:31 
GeneralEmail issue Pin
MyThread22-Mar-05 11:31
MyThread22-Mar-05 11:31 
GeneralRe: Email issue Pin
Dave Kreskowiak22-Mar-05 15:23
mveDave Kreskowiak22-Mar-05 15:23 
QuestionWhy am I getting TypeLoadException? Pin
RvrBndBrewer22-Mar-05 10:14
RvrBndBrewer22-Mar-05 10:14 
AnswerRe: Why am I getting TypeLoadException? Pin
Dave Kreskowiak22-Mar-05 15:18
mveDave Kreskowiak22-Mar-05 15:18 
General.Net 1.1 with Visual Studio.Net 2002 Pin
Anonymous22-Mar-05 10:06
Anonymous22-Mar-05 10:06 
GeneralRe: .Net 1.1 with Visual Studio.Net 2002 Pin
Dave Kreskowiak22-Mar-05 15:14
mveDave Kreskowiak22-Mar-05 15:14 
GeneralRe: .Net 1.1 with Visual Studio.Net 2002 Pin
Christian Graus22-Mar-05 17:32
protectorChristian Graus22-Mar-05 17:32 
General@@Error Pin
Jaydeanster22-Mar-05 7:50
Jaydeanster22-Mar-05 7:50 
GeneralRe: @@Error Pin
Chris Austin22-Mar-05 17:30
Chris Austin22-Mar-05 17:30 
GeneralWeb Browser.Navigate to 2nd URL Pin
Carey Parks22-Mar-05 5:39
Carey Parks22-Mar-05 5:39 
Generalhighlighter in picturebox control Pin
Member 34283522-Mar-05 4:33
Member 34283522-Mar-05 4:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.