VBS Tutorial: function-CStr Function

Source: Internet
Author: User

CStr Function

Return expression, which has been convertedStringChild typeVariant.

CStr(expression)

ExpressionThe parameter is any valid expression.

Description

Generally, code can be written using a subtype Conversion Function to show that the results of some operations should be represented as specific data types, rather than the default type. For exampleCStrForcibly express the resultString.

CStrFunction used to replaceStrFrom other data typesStringSub-types are internationally recognized for format conversion. For example, the identification of the decimal separator depends on the system's region settings.

ExpressionThe returned data is determined based on the following table:

If expression is CStr return
Boolean String, including True or False.
Date StringContains the system's short date format date.
Null Runtime error.
Empty Zero LengthString("").
Error StringContains the word Error with an Error number.
Other values String, Including this number.

The following example usesCStrFunction converts a numberString:

Dim MyDouble, MyStringMyDouble = 437.324         ' MyDouble Is a double precision value.MyString = CStr(MyDouble)  ' MyString Include "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.