Several functions in Visual Basci are split (), UBound (), LBound (), InStr (), Mid ().

Source: Internet
Author: User
Tags array contains functions numeric value return string split
visual| function 1.Split (a string expression that contains substrings and delimiters, [delimiter],[the number of substrings to be returned],[numeric value representing the comparison method to use when distinguishing substrings]), and [] is an optional part. This function returns a one-dimensional array with a zero subscript that contains the specified number of substrings.
Cases:
Dim xx As Variant
Xx=split ("Hello World", "") "divides hello World into Hello and world
text1.text= xx (0) ' Return hello
TEXT2.TEXT=XX (1) ' Return to World
2.Ubound (array name), which returns a Long data whose value is the maximum subscript available for the specified array dimension
Lbound (array name) that returns a Long data whose value is the smallest subscript available for the specified array dimension.
Cases:
Dim xx As Variant
Xx=split ("Hello World", "")
Text1.text=ubound (XX) ' return 1
Text2.text=lbound (XX) ' return 0
3.Instr ([Start,]string1, string2), which returns a Variant (Long) that specifies the position of the first occurrence of a string (string2) in another string (string1), if no return 0 is found. [Start,] is an optional parameter that represents the starting position of the search.
Cases:
Dim xx As String
xx= "Hello World"
Text1.text=instr (xx, "O") ' Return 5
Text2.text=instr (6,xx, "O") ' returns 8, starting with the 6th character
4.Mid (String, start[, length]), which returns a Variant (String) that contains the character of the specified length [, length] in a string, and start as the starting position. where [, length] is an optional parameter without specifying a length, then all characters after start are returned.
Cases:
Dim xx As Sting
xx= "Hello World"
Text1.text=mid (xx,1,5) ' Return hello
Text2.text=mid (xx,1) ' Return to Hello World


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.