Solved

VB.net Get the Next Value of 10

Posted on 2009-04-13
8
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

Author Comment

by:Jimbo99999
ID: 24130660
Ok, that would be great...
Thanks
0
 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

730 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