VBS TUTORIAL: function-strcomp function _vbs

Source: Internet
Author: User

StrComp function

Returns a value that indicates the result of a string comparison.

StrComp(string1, string2[, compare])

Parameters

String1

Required option. Any valid string expression.

string2

Required option. Any valid string expression.

Compare

Options available. Indicates the numeric value of the comparison type to use when calculating the string. If omitted, a binary comparison is performed. For numeric values, see the "Settings" section.

Set up

The compare parameter can have the following values:

Constants value Description
Vbbinarycompare 0 Performs a binary comparison.
vbTextCompare 1 Performs a text comparison.

return value

The StrComp function has the following return value:

if StrComp return
String1 less than string2 -1
String1 equals string2 0
String1 is larger than string2 1
string1 or string2 is Null Null

Description

The following example uses the StrComp function to return the result of a string comparison. If the third argument is 1 to perform a text comparison, if the third argument is 0 or omit to perform a binary comparison.

  Dim MyStr1, MyStr2, MyCompMyStr1 = "ABCD": MyStr2 = "ABCD"  define variable.  MyComp =   StrComp ( mystr1 ,  mystr2 ,  1 )  '      return  0 .  MyComp =   StrComp ( mystr1 ,  mystr2 ,  0 )  '      return -1 .  MyComp =   StrComp ( mystr2 ,  mystr1 )  '     returns  1 . 

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.