• Status: Solved
• Priority: Medium
• Security: Public
• Views: 322
• Last Modified:

# VB.net Get the Next Value of 10

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
Jimbo99999
Asked:
• 4
• 2
• 2
2 Solutions

Commented:
How about
add 9
divide by 10
take the integer amount
multiply by 10.
I'll work out the code if you like. Just shout...
0

Commented:
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

Commented:
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 Commented:
Ok, that would be great...
Thanks
0

Commented:
Only see QuintainT comment .
Sorry about that.
0

Commented:
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

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

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

Thanks for your efforts,
jimbo99999
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Featured Post

• 4
• 2
• 2
Tackle projects and never again get stuck behind a technical roadblock.