Thursday, 15 July 2010

asp classic - Does the part of my string exist in another string? -



asp classic - Does the part of my string exist in another string? -

sorry question, i'm quite rusty on classic asp , can't head around it.

i have variable containing start of series of postcodes:

strpostcode = "hs1,hs2,hs3,hs4,hs5,hs6,hs7,hs8,hs9,iv41,iv42" etc etc

now need see if post code user has entered exists in string.

so, "hs2 4ab", "hs2", "hs24ab" need homecoming match.

any ideas?

thanks

you need split post codes comma go 1 1 , match.

code this:

class="lang-vbs prettyprint-override">dim strpostcode, strinput, x dim arrpostcodes, curpostcode, blnfoundmatch strpostcode = "hs1,hs2,hs3,hs4,hs5,hs6,hs7,hs8,hs9,iv41,iv42" strinput = "hs24ab" arrpostcodes = split(strpostcode, ",") blnfoundmatch = false x=0 ubound(arrpostcodes) curpostcode = arrpostcodes(x) 'if left(strinput, len(curpostcode))=curpostcode if instr(strinput, curpostcode)>0 blnfoundmatch = true exit end if next erase arrpostcodes if blnfoundmatch 'match found, something... end if

the above each post code anywhere in user input e.g. "4ab hs2" homecoming match; if want post code appear in origin of input, utilize alternative if line remarked in above code.

asp-classic postal-code

No comments:

Post a Comment