Monday, January 24, 2011

Converting a number variable into a string 1/24/11

When converting a number variable such as an integer we use the 'ToString' command. You can do it this way and also a different way by using the 'CStr' command. Here I show both ways.

This is the 'ToString' command.

Dim intYahoo As Integer = 8
Dim strYahoo As String = intYahoo.ToString

This is the 'CStr' command.

Dim intYahoo As Integer = 8
Dim strYahoo As String = CStr(intYahoo)

Both of these do the same thing when converting.

1 comment:

  1. I like the explanation and the flow. However, I would like to see more complete code demonstrating the use of each way though:

    Dim intYahoo As Integer = 8
    Dim strYahoo As String = CStr(intYahoo)

    or

    Dim intYahoo As Integer = 8
    Dim strYahoo As String = intYahoo.ToString

    ReplyDelete

Classes

Programming II

Advanced Relational Database

Followers