Recommended: Asp generates a 13-digit random string html title /title body % Functiongen_key(digits) 'Define and initialize the array dimchar_array(80) 'Initialize the numbers Fori=0To9 char_array(i)=CStr(i) Next 'Initialize the uppercase letters Fori=10To35 char_array(i)=Chr(i +55) Next 'Initialize lowercase letters Fori=36To61 char_array(i)=Chr
Storing data using interval strings can reduce the number of database fields to write, and also facilitates expansion of data in the future.For example: in the forum, the user's personality has multiple personalities, optimistic, mature, naive, naughty, gentle and considerate, etc. Their corresponding values are 0, 1, 2, 3, 4 respectively. Use spacer characters when storing these data. String to store data into a text field. The data storage format is: 0|2|3|4|.
When using interval strings to separate various data, the maximum subscript value of the array generated when 0|2|3|4| and 0|2|3|4 are separated using the Split function is often different. If you don't pay attention, an extra space character will be written on the far right. In this way, one more piece of data will be traversed when outputting. In order to avoid this situation, the string must be detected.
Idea:
1. Check whether there is a spacer string on the right side. If it exists, you need to reduce the maximum subscript value of the array by one.
2. If it does not exist, directly return the maximum subscript of the original array.
Code:
DimTempStr,TempArr,TempItem
TempStr=First item 1|Second item 1|Third item|
TempArr=Split(TempStr,|)
Response.WriteTempStr&<br/>
ForTempItem=0ToUBoundStrToArr(TempStr,UBound(TempArr),|)
Response.WriteTempArr(TempItem)&<br/>
Next
'************************
'Function:UBoundStrToArr
'Function: detect the maximum subscript value of the original string converted into an array
'Parameter: cCheckStr (string to be detected)
'cUBoundArr (generates the maximum subscript value of the array)
'cSpaceStr (spacing string)
'Return: the maximum subscript value of the array
'************************
PublicFunctionUBoundStrToArr(ByValcCheckStr,ByValcUBoundArr,ByValcSpaceStr)
IfInstr(cCheckStr,cSpaceStr)=0Then
UBoundStrToArr=cUBoundArr
ExitFunction
EndIf
DimTempSpaceStr,UBoundValue
TempSpaceStr=Mid(cCheckStr,Len(cCheckStr)-Len(cSpaceStr)+1)' Get the space character on the right side of the string
IfTempSpaceStr=cSpaceStrThen'If there is a space character on the rightmost side of the string, the subscript value needs to be -1
UBoundValue=cUBoundArr-1
Else
UBoundValue=cUBoundArr
EndIf
UBoundStrToArr=UBoundValue
EndFunction
Share: ASP+AJAX makes search prompts similar to google The main files are: Index.html implements the function, a text box, inputs content and implements the prompt search.asp query function, allows the content entered in the text box to be queried in the database, and then returns it to the client conn.asp database connection function to implement The core part of xmlhttp.jsAJAX is connected to the database and is used to transfer client data to the server and then transfer the server data to the server.