Some string functions and tips

Source: Internet
Author: User

Technorati Tag: String, vbcrlf, VBA, split

As follows:

  1.  

    Several Characters

    1. CHR (9)Tab vbtab
    2. CHR (10)Line feed
    3. CHR (13)Carriage Return vbcrlf
    4. CHR (32)Space, or yesSpace (1)
      Msgbox Cities (1) & CHR (13) & Cities (2)
  2. Quoted text embedded in a text string requires an additional set of quotation marks, as in"" Test.doc "".

  3. To get the same result, you can replace CHR (9) with a VBA constant: vbtab.

  4. Note: vbcrlf is a string of 2 characters. For example, if the last character of a string is vbcrlf, you can use the right function to retrieve the last character and ask whether it is equal to vbcrlf. The answer is false; however, if you take the rightmost 2 characters, you can get the vbcrlf

  5. Isnumeric checks whether all strings are numbers.

  6. Right, left, mid, and instr are all easy-to-use functions used to access individual characters in strings.

  7. Format FunctionUsed to format strings

  8. Split Function

      1. Public sub test ()
      2. Dim shoppinglist as string
      3. Dim shoppingitem () as string
      4. Shoppinglist = "milk, eggs, bread"
      5. Shoppingitem = Split (expression: = shoppinglist, delimiter: = ",")
      6. Msgbox "0:" & shoppingitem (0) & CHR (13) & "1:" & shoppingitem (1) & CHR (13) & "2:" & shoppingitem (2)
      7. End sub

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.