+92 332 4229 857 99ProjectIdeas@Gmail.com

Conversion-Integer to String (Vb.net)


How to convert integer to string (Vb.net)

If Option Strict is Off, then (integer)x will implicitly be converted into (string)str.
Example:

Dim intVal As Integer = 5
Dim strVal As String = String.Empty
strVal = intVal
MsgBox(strVal)
But if Option Strict is On, then the (integer)x will not be implicitly converted into (string)str. In this case, we will have to use the conversion function.
Example1:

Dim intVal As Integer = 5
Dim strVal As String = String.Empty
strVal = CStr(intVal)
MsgBox(strVal)
Example 2:

Dim intVal As Integer = 5
Dim strVal As String = String.Empty
strVal = CType(intVal, String)
MsgBox(strVal)

0 comments: