Ensuring Division By 5 on Whole Number VB6

Qpido

New Member
Joined
Oct 9, 2007
Messages
30
I am trying to write a piece of code in VB6 that checks to make sure the input is a multiple of 5.

There are 2 text boxes, one with a minimum value and one with a maximum value.

I want the input to go to the nearest rounded 5 divisional possibility.

Where do I begin?

I then export these to Excel for posting (which isn't the problem in this case, just FYI).

Thanks for your advice.

Jerome
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
I am trying to write a piece of code in VB6

Hello Jerome

This is a forum on VBA within Excel, not VB6.

You could use the function MROUND in Excel and also in VBA:

For instance:

Code:
MsgBox WorksheetFunction.MRound(CDbl(TextBox1.Text), 5)
 
Upvote 0
In VB6 you could use the Mod operator to determine if a number is divisible by 5. The Mod operator returns a 'remainder' if one nubmer is not divisible by another.

Code:
If CLng(YourTextBox.Text) Mod 5 > 0 Then
     MsgBox "Not divisible by 5"
End If
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,277
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top