Solved

VB.net Get the Next Value of 10

Posted on 2009-04-13
8
314 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

919 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

21 Experts available now in Live!

Get 1:1 Help Now