Rounding up all odd numbers

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Can someone please explain to me what I need to do to get it so when my users
are entering an item into a form and it is an odd number to automatically
round that number up so it is even. I only want odd numbers to round. If an
even is input, I need to to stay as is.

Any help would be great!
 
TROUBLED said:
Can someone please explain to me what I need to do to get it so when
my users are entering an item into a form and it is an odd number to
automatically round that number up so it is even. I only want odd
numbers to round. If an even is input, I need to to stay as is.

Any help would be great!

Are you talking about "rounding up" whole numbers, so that odd numbers
such as 1, 3, 5 are always adjusted to the next higher number, such as
2, 4, 6? If so, you could use code in the AfterUpdate event of the text
box where the number is entered. For example:

'----- start of example code -----
Private Sub TheNumber_AfterUpdate()

With Me.TheNumber
.Value = .Value + (.Value Mod 2)
End With

End Sub
'----- end of example code -----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top