vb.net - Retrieve starting positions of the titles in the string -
i have line of 7 different titles can consist of 1 or 2 words @ least 3 or 4 spaces between title.
" company name contact name address city state zip phone"
i need retrieve position in line each title begins. use indexof:
pos1 = line.indexof("company", system.stringcomparison.invariantcultureignorecase)
this method works fine not efficient retrieving positions since line comes text documents , there great variability, example might have this:
" c0mpany name c0ntact name address ncity st)te zip phone"
so wording not exact. know there 7 columns. best way retrieve 7 beginning positions of columns programmatically?
this works quite well
dim s string dim v object dim tok object s = " c0mpany name c0ntact name address ncity st)te zip phone" v = split(s, " ") each tok in v if len(trim(tok)) > 0 debug.print(tok & vbtab & instr(s, tok)) end if next
output:
c0mpany name 3 c0ntact name 23 address 41 ncity 60 st)te 69 zip 78 phone 85
the above in access vba, here same code after cut + paste vb.net
Comments
Post a Comment