CStr Function

Tips >>ASP Functions

WANTS TO MAKE SOFTWARE WITHOUT KNOWLEDGE OF ASP? CLICK HERE


CStr function converts variant of subtype string. In general, you can document your code using the data type conversion functions to show that the result of some operation should be expressed as a particular data type rather than the default data type. For example, use CStr to force the result to be expressed as a string. You should use the CStr function instead of Str to provide internationally aware conversions from any other data type to a String subtype. For example, different decimal separators are properly recognized depending on the locale setting of your system. The CStr function converts an expression to type String.


The Syntax of CStr function is :-

CStr(expression)

The data in expression determines what is returned according to the following table :-

If expression isCStr returns
BooleanA String containing True or False.
Date A String containing a date in the short-date format of your system.
Null A run-time error.
EmptyA zero-length String ("").
ErrorA String containing the word Error followed by the error number.
Other numeric A String containing the number.

Example#1 :-

Code :-
dim a
a=false
document.write(CStr(a))
Output :-
False

Example#2 :-

Code :-
dim a
a=#10/01/06#
document.write(CStr(a))
Output :-
10/1/2006

Example#3 :-

Code :-
Dim MyDouble, MyString MyDouble = 437.324 '
MyDouble is a Double. MyString = CStr(MyDouble) '
MyString contains "437.324".
Output :-

Hence, CStr contains "437.324"

 

 
E-mail : sales@virtualsplat.com
Phone : +91-9892413501

+91-9967648641

+91-9967648641