Solved

# VB.net Get the Next Value of 10

Posted on 2009-04-13
315 Views
Good Day

Experts:

I am having a bit of difficulty working through this seemingly "easy" idea I need to accomplish.
I have an integer variable and need to find the next multiple of 10.  So 7 would be 10, 13 would be 20, 27 would be 30 and so on.

Can anyone help me with how I might be able to programatically figure this out?

Thanks,
jimbo99999
0
Question by:Jimbo99999
• 4
• 2
• 2

LVL 5

Assisted Solution

QuintainT earned 200 total points
ID: 24130609
divide by 10
take the integer amount
multiply by 10.
I'll work out the code if you like. Just shout...
0

LVL 33

Expert Comment

ID: 24130641
Try this
``````    Sub Main()
Console.WriteLine(GetNextMultipleOfTen(7))
Console.WriteLine(GetNextMultipleOfTen(13))
Console.WriteLine(GetNextMultipleOfTen(27))
End Sub
Public Function GetNextMultipleOfTen(ByVal i As Integer)
Dim j As Integer = i + 10
j = Math.Truncate(j / 10)
j = j * 10
Return j
End Function
``````
0

LVL 33

Accepted Solution

hongjun earned 300 total points
ID: 24130648
To correct,

``````    Sub Main()
Console.WriteLine(GetNextMultipleOfTen(7))
Console.WriteLine(GetNextMultipleOfTen(10))
Console.WriteLine(GetNextMultipleOfTen(13))
Console.WriteLine(GetNextMultipleOfTen(27))
End Sub
Public Function GetNextMultipleOfTen(ByVal i As Integer)
Dim j As Integer = i + 9
j = Math.Truncate(j / 10)
j = j * 10
Return j
End Function
``````
0

Author Comment

ID: 24130660
Ok, that would be great...
Thanks
0

LVL 33

Expert Comment

ID: 24130664
Only see QuintainT comment .
0

LVL 5

Expert Comment

ID: 24130701
hongjun's code looks like it should work so I'd go with that. (I'd have done it slighly differently, but no better...:O)
0

LVL 33

Expert Comment

ID: 24130712
QuintainT deserves the effort too for the quick pseudocode posted.
0

Author Closing Comment

ID: 31569545
I split up the points as hongjun came up with the on paper logice and QuintainT for the code.

jimbo99999
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB â€¦
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itselâ€¦
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.