Example Code:
a memo report weather and date in one data cell or a text file
weather=
"1/1/2006w:sun,1/2/2006w:rain,1/3/2006w:storm,1/4/2006w:...."
<%
dim weather,dayArray,queryDay
queryDay="8/6/2006"
weather=request("weather")
dayArray=Split(weather,",")
' if the end of weather string is ( , ) then UBound(dayArray)-1
for I=0 to UBound(dayArray)-1 ' -1 is for ( , ) ending
' way 1 ---- filter to find queryDay
TrueDayArray=Filter(dayArray,queryDay)
if TrueDayArray(0)<>empty then
document.write(replace(TrueDayArray(0),"w:"," weather is "))
end if
' way 2 ---- instr to find queryDay
if instr(dayArray(I),queryDay)>0 then
response.write replace(dayArray(I),"w:"," weather is ")&"<br>"
response.write replace(dayArray(I),queryDay&"w:","")
end if
next
%>
Filter 常配合 Split, UBound, Array, instr,
replace 更加方便呼叫出所要的資料 |