Convert string by different base : Convert « Development « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Date Time
8.Development
9.Event
10.File Directory
11.Generics
12.GUI
13.Internationalization I18N
14.Language Basics
15.LINQ
16.Network Remote
17.Reflection
18.Security
19.Thread
20.Windows Presentation Foundation
21.Windows System
22.XML
23.XML LINQ
VB.Net » Development » ConvertScreenshots 
Convert string by different base
  

Module Example
   Public Sub Main()
      Dim bases() As Integer = 281016 }
      Dim values() As String = "-1""1""08""0F""11" "12""30", _                
                                  "101""255""FF""10000000""80" }
      Dim number As Byte
      For Each base As Integer In bases
         Console.WriteLine("Base {0}:", base)
         For Each value As String In values
            Try
               number = Convert.ToByte(value, base)
               Console.WriteLine("   Converted '{0}' to {1}.", value, number)
            Catch As FormatException
               Console.WriteLine("   '{0}' is not in the correct format for a base {1} conversion.", _
                                 value, base)
            Catch As OverflowException
               Console.WriteLine("   '{0}' is outside the range of the Byte type.", value)
            Catch As ArgumentException
               Console.WriteLine("   '{0}' is invalid in base {1}.", value, base)
            End Try   
         Next                                 
      Next 
   End Sub
End Module

   
    
  
Related examples in the same category
1.Convert.ChangeType
2.Convert numeric string to SByte without a format provider
3.Convert numeric string to SByte with a format provider.
4.Converting strings to numbers in base
5.Convert.ToBase64CharArray converts 8-bit unsigned integer array to Unicode character array
6.Convert the Char array back to a Byte array
7.Convert.ToBase64String converts 8-bit unsigned integers to string encoded with base-64 digits.
8.Convert.ToDateTime (Object) converts object to a DateTime object.
9.Convert.ToDateTime Method (Object, IFormatProvider) converts object to DateTime using culture-specific format
10.Convert.ToDateTime(String) converts string to date and time value.
11.Convert.ToDateTime(String, IFormatProvider) converts string to date and time, using culture-specific format
12.Convert single value to decimal
13.Convert hex string to Int16
14.Convert hex string to int64
15.Convert Long to Integer
16.Convert double to Integer
17.Convert BigInteger to Integer
18.Convert decimal to Integer
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.