Solved

VB.net Get the Next Value of 10

Posted on 2009-04-13
8
313 Views
Last Modified: 2012-05-06
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
Comment
Question by:Jimbo99999
  • 4
  • 2
  • 2
8 Comments
 
LVL 5

Assisted Solution

by:QuintainT
QuintainT earned 200 total points
ID: 24130609
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
 
LVL 33

Expert Comment

by:hongjun
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

Open in new window

0
 
LVL 33

Accepted Solution

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

Open in new window

0
 

Author Comment

by:Jimbo99999
ID: 24130660
Ok, that would be great...
Thanks
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 33

Expert Comment

by:hongjun
ID: 24130664
Only see QuintainT comment .
Sorry about that.
0
 
LVL 5

Expert Comment

by:QuintainT
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

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

Author Closing Comment

by:Jimbo99999
ID: 31569545
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

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now