?
Solved

VB.net Get the Next Value of 10

Posted on 2009-04-13
8
Medium Priority
?
319 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 800 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 1200 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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