dr_dudd
asked on
String Manipulation and maths
I have a result passed to me as a result of an sql query it is a string.
the string for example would be 03 02:45:00
This represents the duration of a trip.
I need to be able to perform some maths on this string in seperate sections......
I need the first two digits in the string to be *24 then *6 and return a value i then the next 2 digit to be *6 and added to the first value, finally i need the next two digits to be /10 then added to the total, the last two digits are to be ignored.
eg.,..03 02:45:00 would be ((03*24)*6)+(02*6)+(45/10) giving me and end result of 448
Could anyone help me with some pointers for Visual Basic code to do this?
the string for example would be 03 02:45:00
This represents the duration of a trip.
I need to be able to perform some maths on this string in seperate sections......
I need the first two digits in the string to be *24 then *6 and return a value i then the next 2 digit to be *6 and added to the first value, finally i need the next two digits to be /10 then added to the total, the last two digits are to be ignored.
eg.,..03 02:45:00 would be ((03*24)*6)+(02*6)+(45/10)
Could anyone help me with some pointers for Visual Basic code to do this?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It helps if you identify in a non-coding-language-specif ic topic which language you're using.
By declaring that youw were using visual basic, it was assumed, that you meant vb6.
"Could a moderator please close the question."
Moderators don't continually monitor threads, you need to post such a request in http:/Community_Support/
By declaring that youw were using visual basic, it was assumed, that you meant vb6.
"Could a moderator please close the question."
Moderators don't continually monitor threads, you need to post such a request in http:/Community_Support/
Just click split points and divide them between the comments that were actual answers, CS has lots to do
ASKER
Dim days As String
Dim daysint As Integer
Dim hours As String
Dim hoursint As Integer
Dim minutes As String
Dim minutesint As Integer
Dim length As Integer
days = .GetString(2)
daysint = days.Substring(0, 2)
daysint = (daysint * 24) * 6
hours = .GetString(2)
hoursint = hours.Substring(3, 2)
hoursint = (hoursint * 6)
minutes = .GetString(2)
minutesint = minutes.Substring(6, 2)
minutesint = (minutesint / 10)
length = daysint + hoursint + minutesint
Could a moderator please close the question.