VB string to integer

In VB (.NET) programming language, you are able to convert a string ( of a number) to an integer value by using the Parse(string) method of the Integer type. In the example below, the Console.ReadLine() method is used to read the string of a number from keyboard. Then this string is converted to integer by using Integer.Parse method.

Module Module1
   Sub Main()
     Dim rn As Random
     Dim n As Integer
     Dim value As Integer
     rn = New Random() 'create random object
     n = rn.Next(1, 100) 'get random value from 1 to 100
     Console.Write("Enter your number:")
     value = Integer.Parse(Console.ReadLine()) ' Convert from string to integer
     If n = value Then
        MsgBox("Incorrect! My numer is " & n & ".")

     End If
  End Sub
End Module

Posted by: Ly Meng | post date: 02-06-2013 | Subject: VB.NET Programming Language

This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.