If any body help me, I shall be very greatful:

How shall we write Code using VB so that the value of the product of two variable should be rounded to the nearest Integer number which is divisible by 5.

Is there any way to check whether the given number is divisible by a a number (Say 7).

Hi, Mr. debasisdas,
thank you very much for your response. I wamt to tell you that Ican round the number only to the nearest number by writing like this:
C=AXB
D=round(Val(C)+0.001)

But I do not know how to write the code so that the number should be rounded to the nearest integer and nearest number which is divisible by a given number (Say 10)
eg. If a number to be rounded up is 785 it will be rounded upto 780, 788 will be rounded upto 790

I also want to know the code so as to be able to check whether a given number is divisible by some given number (Say 7) or not.

KVL Liana

Hi,
It is simple logic.

> First Add half of that number (788 + (10/2) = 793)
 > Take Modulus (793 MOD 10 = 3), You get the remainder (3)
 > Subtract the Remainder from that Number (793 - 3)

OR

> First Add half of that number (788 + (10/2) = 793)
 > Divide the Number (793 by 10 ), you get the quotient (79.3)
 > Split the Integer part only  (Int(79.3) = 79)
 > Again multiply by that Number (79 * 10 = 790)

OR

> Take Modulus (788 MOD 10 = 8), You get the remainder (8)
 > If Remainder > 5 Then 
 > .....
 > Else
 > ...

In this way you can round of the number.
Also you can customize this for your need.
I hope this is helpful for you

This article has been dead for over six months. Start a new discussion instead.