ASP learning the FSO component Operation example skill (7)

Source: Internet
Author: User
fso| Skills

<script language=vbs>
my_string = "a110b121c119d1861"
A_value = Mid (my_string,2,3)
Alert (A_value)
</script>

But imagine: if not "110", but "1100", that is not to extract 4 bits ... This shows that the procedure is not perfect.

So keep thinking: the extracted value is always after the letter "a", and the value is always between the letter "a" and "B", so as long as the "a", "B" position, then the starting bit of the median value should be the letter "a" bit +1, the middle value should be the length of the letter "B" bit-The letter "A" bit-1

So now you can make the program perfect:

<script language=vbs>
my_string = "a110b121c119d1861"
A_num = InStr (my_string, "A")
B_num = InStr (my_string, "B")
A_value = Mid (My_string,a_num+1,b_num-a_num-1)
Alert (A_value)
</script>

OK, so now you can completely extract the value one by one after the letter "B", "C", and "D".

Of course, we need to pay attention to the "D" after a few how to take it? Take the total length of the string-the number of places where the letter D is.

<script language=vbs>
my_string = "a110b121c119d1861"
A_num = InStr (my_string, "A")
B_num = InStr (my_string, "B")
C_num = InStr (my_string, "C")
D_num = InStr (my_string, "D")
Total_num = Len (my_string)
A_value = Mid (My_string,a_num+1,b_num-a_num-1)
B_value = Mid (My_string,b_num+1,c_num-b_num-1)
C_value = Mid (My_string,c_num+1,d_num-c_num-1)
D_value = Mid (My_string,d_num+1,total_num-d_num)
Alert (A_value)
Alert (B_value)
Alert (C_value)
Alert (D_value)
</script>







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.