CStr


Definition: Returns an expression that has been converted to a Variantof subtype String.

 

There will be times (especially when you work with databases) when you’ll have a numeric value that needs to be treated as a string. Can you convert a numeric value into a string value? Of course you can. To begin with, assign the numeric value to a variable (in this example, we assign 17 to $a):

 

$a = 17

 

If we want to verify that $a is really a numeric value we can do this using the GetType ( )method:

 

IsPublic IsSerialName
-------- -------- ----
True     True     Int32

 

Now, what about converting this to a string value? Here you go:

 

$a = [string] $a

 

When you run this command and then check the data type of $ a youshould get the following:

 

IsPublic IsSerialName
-------- -------- ----
True     True     String