VBScript CStr Function

## VBScript Tutorial

VB HOME VB How to VB Variables VB Procedures VB Conditional VB Looping VB Summary

## VB Examples

VB Examples

## VB References

VB Functions VB Keywords

# VBScript CStr Function

Complete VBScript Reference

The CStr function converts an expression to type String.

### Syntax

CStr(expression)

Parameter | Description
--- | ---

expression

Required. Any valid expression

If expression is:

- Boolean - then the CStr function will return a string containing true or false.
- Date - then the CStr function will return a string that contains a date in the short-date format.
- Null - then a run-time error will occur.
- Empty - then the CStr function will return an empty string ("").
- Error - then the CStr function will return a string that contains the word "Error" followed by an error number.
- Other numeric - then the CStr function will return a string that contains the number.

## Example

<script type="text/vbscript">
document.write(CStr("300000") & "<br />")
document.write(CStr(#10-05-25#) & "<br />")
</script>

The output of the code above will be:

300000
10/5/2025
Try it yourself »

Complete VBScript Reference

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE