VBS TUTORIAL: function-CSTR function _vbs

Source: Internet
Author: User

CStr function

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

CStr(expression)

The expression parameter is any valid expression.

Description

In general, you can use a subtype conversion function to write code to show that the results of some operations should be represented as a specific data type, not the default type. For example, use CStr to force the result to be represented as a String.

The CStr function is used to override the Str function for internationally recognized format conversions from other data types to String subtypes. For example, the recognition of the decimal separator depends on the locale of the system.

expression determines the data returned according to the following table:

If expression is CStr return
Boolean A string that contains True or False.
Date A string that contains the system's short date format date.
Null Run-time error.
Empty 0 Length string ("").
Error string that contains the word error following the error number.
Other values A string containing this number.

The following example converts a number to a Stringusing the CStr function:

  Dim mydouble, mystringmydouble = 437.324 ' MyDouble  is a double value.  MyString =  CStr ( mydouble )  ' MyString    Contains the  437.324 . 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.