Join 150,086 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,781 people online right now. Registration is fast and FREE... Join Now!
I m not familiar with Javascript coding however i m converting one algorithm from javascript to vb.net class. i m stuck at a function for which i m unable to guess what it meant so please just elaborate a little bit that what the following functions does so i would be able to correct it.
CODE
hours = (hours+ 12 -1)% 12+ 1;
The main problem is the % sign that what it does actually.
If you want to calculate for 16 hours then the variable hours should have the value of 16, not the way you're doing this. Now Im moving this to the VB.NET Forum where it belongs
If you want to calculate for 16 hours then the variable hours should have the value of 16, not the way you're doing this. Now Im moving this to the VB.NET Forum where it belongs
Well, sorry buddy i just copy pasted my workout to get correct value.
But the error mentioned occurs If i just place 16 instead of hour with the same syntax u gave then it is resulting 1
vb.net
(16 + (12 - 1)) Mod (12 + 1)
Thanks for the time u r giving me but actually the conversion is done but probably this statement is not giving me desired results. I m just stuck in it.
they have tried to show you that the 1 IS correct the way you have the code right now. Let me break something down
MOD: Divide the part after mod into the part before it. Display the remainder.
now lets get into the actual math of it again:
hours = 16
16+12-1 = 28-1 = 27
12+1 = 13
so 27 /13 = 2 with a remainder of 1 so the output is 1. I don't understand how you think this is wrong. From a coding logic it is right, and from a mathematical standpoint it is right, what you have on your hands is wrong code.
Go back and rethink the way you have your code.
hours = (16 + 12 - 1) Mod (12+1) will never = 4. Sorry bud.
now, i think there is some loss in translation stuff going on here. Please describe exactly what you are trying to do so that we might be able to understand your problem a bit better.
what i am thinking:
you want to be able to convert 24 hour time to 12 hour time I.E
take 22 hundred hours and change it to 10PM. am i correct in this thinking?
This post has been edited by rgfirefly24: 5 Jun, 2008 - 04:29 AM