|
-
Jun 12th, 2002, 03:10 AM
#1
Thread Starter
Hyperactive Member
Thx for the code mendhak! But this will still give me 8,12. Another try???
-
Jun 12th, 2002, 03:12 AM
#2
OK, explain how you got the 2 there.
I got the '8' part, but the '2' part wasn't so clear.
-
Jun 12th, 2002, 03:21 AM
#3
Thread Starter
Hyperactive Member
1 Hour = 60 minutes, i got to split his 60 minutes up into 10 periods. Then each period will be 6 minutes.
12 minutes is then the same as 2 periods (12/6=2)
Got it??
-
Jun 12th, 2002, 03:27 AM
#4
Well, didn't you just answer your own question. 
VB Code:
Dim abc As Integer
abc = (DateDiff("n", "08:00", "16:12"))
Dim def As Integer
def = abc / 60
Dim ghi As Single
ghi = abc Mod 60
MsgBox (def & "," & ghi / 6)
-
Jun 12th, 2002, 05:05 AM
#5
First of all use dim abc as single. A simple dim abc is bad coding.
when you apply format() it too rounds up you function.
now, your division yields 8.99996
The only way I can think of right now is to convert that to string, extract upto the first char after the decimal, and reconvert back to single.
Is that OK with u?
-
Jun 12th, 2002, 05:09 AM
#6
VB Code:
Dim abc As Single, begin As Integer, temp As String
abc = (DateDiff("n", "08:00", "16:58")) / 60
mytime = Format(abc, "#.#")
begin = InStr(CStr(abc), ".")
temp = Mid(CStr(abc), 1, begin + 1)
mytime = CSng(temp)
MsgBox mytime
-
Jun 12th, 2002, 05:46 AM
#7
Thread Starter
Hyperactive Member
Have you tested your code?
mytime = 8
-
Jun 12th, 2002, 05:49 AM
#8
I got 8.9
what have you changed? Post ur code again.
-
Jun 12th, 2002, 05:59 AM
#9
Thread Starter
Hyperactive Member
Here we go:
Dim abc As Single, begin As Integer, temp As String
abc = (DateDiff("n", "08:00", "16:58")) / 60
mytime = Format(abc, "#.#")
begin = InStr(CStr(abc), ".")
temp = Mid(CStr(abc), 1, begin + 1)
mytime = CSng(temp)
MsgBox mytime
I am so glad that u will help.....
-
Jun 12th, 2002, 06:03 AM
#10
Dude, I got 8.9 with ur code.
Try again.
I'm going home right now (Mongolia time: 6:30 pm) I'll be at home later, I can check it out then if u aren't in a rush. else grab someone else here.
cya
-
Jun 12th, 2002, 06:54 AM
#11
Thread Starter
Hyperactive Member
Im not in a rush. Take your time...
-
Jun 12th, 2002, 10:48 AM
#12
Ok, I'm still getting 8.9.
Did you try again? Maybe you have VB Weirdo version or something 
Maybe you should take my code and start again.
-
Jun 12th, 2002, 12:39 PM
#13
Thread Starter
Hyperactive Member
Yepp! Still got 8. Can it be something that is different beacuse of my languagesettings? (Swedish)
-
Jun 12th, 2002, 11:31 PM
#14
Originally posted by Libero
Yepp! Still got 8. Can it be something that is different beacuse of my languagesettings? (Swedish)
Maybe you're implying that the Swedes don't know how to perform simple mathematical operations? 
OK, I think you should step through your code then.
Place a breakpoint next to each and every line and check all the values you're getting. I seriously doubt it would be a problem with your language settings or even your processor for that matter.
-
Jun 13th, 2002, 12:02 AM
#15
Thread Starter
Hyperactive Member
-
Jun 13th, 2002, 12:19 AM
#16
Thread Starter
Hyperactive Member
-
Jun 13th, 2002, 12:22 AM
#17
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|