Methods for converting strings into Entity classes in ASP (optimization, simple optimization)

Source: Internet
Author: User

Option explicit <br/> dim str1, str2 <br/> str1 = "order | Shiyang: 100, mayang: 200 "<br/> str2 =" book | Shuming: Computer, dingjia: 100 "<br/> 'declare two global objects <br/> 'abandoned the method of array storage at the beginning, although it is more efficient, however, you need to customize the array_pushobj function, so we will not discuss it here <br/> dim objname_g <br/> dim classname_g <br/> 'Return entity class <br/> function getobjmod (byval Str) <br/> dim classname, itemlist, I <br/> dim execstr <br/> classname = Split (STR, "|||") (0) <br/> execstr = "class" & classname & CHR (10) <br/> itemlist = Split (split (STR, "|") (1 ),", ") <br/> for I = 0 to ubound (itemlist) <br/> execstr = execstr +" public "& Split (itemlist (I ),":") (0) & CHR (13) & CHR (10) <br/> next <br/> execstr = execstr & "End Class" & CHR (13) & CHR (10) & _ <br/> "set objname_g = new" & classname </P> <p> classname_g = classname <br/> execute execstr </P> <p> end function <br/> 'assign value <br/> function getobjcon (byval Str) <br/> dim itemlist, I, execstr <br/> If classname_g = Split (STR, "|") (0) and isobject (objname_g) then <br/> set getobjcon = objname_g <br/> else <br/> getobjmod (STR) <br/> set getobjcon = objname_g <br/> end if <br/> itemlist = Split (split (STR, "|") (1 ),",") <br/> for I = 0 to ubound (itemlist) <br/> execstr = execstr + "getobjcon. "& Split (itemlist (I),": ") (0) &" = "" & Split (itemlist (I), ":") (1) & "& CHR (13) & CHR (10) <br/> next <br/> execute execstr <br/> end function <br/> 'test function <br/> sub ceshi3 <br/> dim I, o1 <br/> for I = 0 to 10000 <br/> set O1 = getobjcon (str1) <br/> response. write o1.shiyang & "<br>" <br/> next <br/> set O1 = getobjcon (str2) <br/> response. write o1.shuming & "<br>" </P> <p> end sub <br/> dim t1 <br/> T1 = timer () <br/> call ceshi3 <br/> response. write formatnumber (timer ()-T1), 4,-1) <br/> 

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.