ASP 从数组中删除值

'This function returns a copy of the array with all instances of the specified value removed
function removeValueFromArray(byval arrayName, valueToRemove)
	amountFound = 0 'keeps track of how many it found so that it knows what size to redim the array at the end
	topIndex = ubound(arrayName) 'hold the value of the ubound in a variable so that you can decrement it when you find the value to remove
	for i = 0 to ubound(arrayName)
		if i > topIndex then 'this keeps the loop from checking past the topIndex. keeps the loop from being infinite when the last value
			exit for ' exit the loop when you have reached the end of the checked values
		end if
		if arrayName(i) = valueToRemove then
			topIndex = topIndex - 1 'decrement the topIndex when you shift down so that it doesn't check the duplicated values at the end of the array
			amountFound = amountFound + 1 ' the value has been found so increment
			for j = i to (ubound(arrayName) - 1) 'shift the array values left to overwrite the value to remove
				arrayName(j) = arrayName(j + 1)
			next
			'if the next element was equal to valueToRemove you have to go back and get rid of it too
			if arrayName(i) = valueToRemove then
				i = i - 1 ' this gets incremented at the beginning of the loop so don't worry about negative values
			end if
		end if
	next
	redim preserve arrayName(ubound(arrayName) - amountFound)
	removeValueFromArray = arrayName
end function

ASP 缩短文本ASP功能

Function shortenText(text, length, append)
	if (Len(text) > length) then 'shorten if greater than length
		descriptionArr = Split(text, " ") 'split words into an array
		text = ""
		for i = 0 to UBound(descriptionArr)
			descriptionWord = descriptionArr(i)
			if (Len(descriptionWord) + Len(text) + 1 <= length) then 'if new word plus sentence being put together is shorten than length'
				text = text & descriptionWord & " "
			else
			exit for
			end if
		next
		if append <> "" then
			text = text & append
		end if
		shortenText = text
	else 
		shortenText = text
	end if
End Function

ASP 选项卡标题实现

<span class="tab" tabIndex="[[Tab Index(1)]]" tabID="[[Tab ID (tab1)]]">[[Tab Title]]</span>

ASP 标签内容 - 信息页面

<div class="tab" id="[[tab1]]">
													<table style="TABLE-LAYOUT: fixed" cellSpacing="0" cellPadding="3" width="100%">
														<COLGROUP>
															<col width="115">
															<col>
															<col style="PADDING-LEFT: 20px" width="135">
															<col>
														</COLGROUP>
<tr>
<td class="NotReq">Call Center ID</td><td><input id="wooCallCenterID" class="num" readonly tabIndex="" type="text" value="<%# workorderEx.wooCallCenterID %>" maxLength="50" min="-100000000000" max="100000000000" grp="true" acc="0" dt="unformatted" returnValue="" runat="Server"></td>
<td class="Req">Branch</td><td><table style="TABLE-LAYOUT: fixed" cellSpacing="0" cellPadding="0" width="100%"><tr><td noWrap><div class="search"><span class="lui" onclick="openStdWin('../Branch/BranchInformation.aspx?braID=' + wooBranch_braIDFK.value);"><%# GetRelatedInnerHtml("../_imgs/ico_16_Branch.gif", workorderEx.wooBranch) %></span></div></td><td width="25"> <IMG runat="server" id="wooBranch_braIDFKSearchImage" class="search" tabIndex=""  dialogWidth="950" dialogHeight="500" dialogArgs="" searchURL="../Branch/BranchSearch.aspx" src="../_imgs/btn_off_lookup.gif"><input id="wooBranch_braIDFK" name="wooBranch_braIDFK" type="hidden" value="<%# workorderEx.wooBranch_braIDFK %>" runat="server"></td></tr></table></td>
</tr>
<!-- Add code here  -->



													</table>
												</div>

ASP 标签内容 - 儿童

<div id="[[tab id - tab1]]" class="tab" style="PADDING-RIGHT:10px;DISPLAY:inline;PADDING-LEFT:10px;PADDING-BOTTOM:10px;PADDING-TOP:10px">
						<table width="100%" height="100%" cellspacing="0" cellpadding="0">
							<tr height="20">
								<td width="100%">
									<table class="menuBar" id="[[MenuBar ID - mnuBar1]]" cellSpacing="0" cellPadding="0">
										<tr>
										<td class="menuBarGroup" noWrap>
											<div id="[[Action ID - menuBar]]">
												<span class="actionMenu" nowrap>Actions<IMG src="../_nav/mnuDown.gif" id="[[Action img id - imgMenu]]">
										<uif:actionMenu id="[[Action menu id - actionmenu]]" runat="server"></uif:actionmenu>
												</span>
											</div>
										</td>
										<td class="menuBarGroup menuRight" noWrap><span id="[[New Button ID - newButton]]" runat="server" class="menuBarButton" title="Add a Problem Location/Symptom" onclick="openStdWin(editURL);"
											tabIndex="0"><IMG class="menuBarImage" src="../_imgs/ico_16_WorkOrderProblemLocationSymptom.gif"> Add Problem Location/Symptom</span><span id="[[Delete Buttion id - deleteButton]]" runat="server" class="menuBarButton" title="Delete Selected Problem Location/Symptoms" onclick="[[deleteProblemLocationSymptoms]]();"
											tabIndex="0"><IMG class="menuBarImage" src="../_imgs/16_L_remove.gif"> Delete Problem Location/Symptoms</span><span class="menuBarButton" title="Print" onclick="printGrid('Grid', '1');" tabIndex="0"><IMG class="menuBarImage" src="../_imgs/16_print.gif">
											</span><span class="menuBarButton" title="Export to an Excel spreadsheet" onclick="exportToExcel('[[Grid Frame ID - Grid]]', '1');"
												tabIndex="0"><IMG class="menuBarImage" src="../_imgs/16_excel.gif">
											</span></td>
										</tr>
									</table>
									<div style="BORDER-TOP: #969693 1px solid; BORDER-BOTTOM: #c2c2bf 1px solid"></div>
								</td>
							</tr>
							<tr>
								<td colSpan="2">
									<table height="100%" cellSpacing="0" cellPadding="0" width="100%">
										<tr>
											<td colSpan="2"><iframe class="grid" id="[[Grid Frame ID - Grid]]" src="[[WorkOrderChildProblemLocationSymptomGrid.aspx]]?container=true&parentID=<%# ParentIDString %>" frameBorder="0"
													scrolling="auto"></iframe></td>
										</tr>
										<tr height="22">
											<td>
												<table class="gridStatusBar gridBar" id="[[Grid_StatusBar]]" cellSpacing="0" cellPadding="0">
													<tr>
														<td> </td>
														<td id="[[Grid_PageInfo]]" align="right"><IMG id="_prevPageImg" onclick="[[Grid_StatusBar]].LoadPage();" hspace="6" src="../_imgs/page_L0.gif"
																align="absMiddle">Page <span id="_PageNum">1</span>
															<IMG id="_nextPageImg" onclick="[[Grid_StatusBar]].LoadPage(true);" hspace="6" src="../_imgs/page_R0.gif"
																align="absMiddle"> </td>
													</tr>
												</table>
											</td>
										</tr>
										<!--tr height="22">
											<td>
												<table class="gridJumpBar gridBar" id="[[Grid_JumpBar]]" cellSpacing="0" cellPadding="2">
													<tr title="View records starting with this letter">
														<td title="View all records" noWrap width="5%">All</td>
														<td title="View records starting with a number">#</td>
														<td>a</td>
														<td>b</td>
														<td>c</td>
														<td>d</td>
														<td>e</td>
														<td>f</td>
														<td>g</td>
														<td>h</td>
														<td>i</td>
														<td>j</td>
														<td>k</td>
														<td>l</td>
														<td>m</td>
														<td>n</td>
														<td>o</td>
														<td>p</td>
														<td>q</td>
														<td>r</td>
														<td>s</td>
														<td>t</td>
														<td>u</td>
														<td>v</td>
														<td>w</td>
														<td>x</td>
														<td>y</td>
														<td>z</td>
													</tr>
												</table>
											</td>
										</tr-->
									</table>
								</td>
							</tr>
						</table>
					</div>

ASP 将ASP代码页设置为UTF-8

<%
Response.CodePage = 65001
Response.CharSet = "utf-8"
%>

ASP 一般字符串函数

' Count the chars in a string
' =========
response.write(len("1234567"))
' Output: 7
' =========

' Edit date
' =========
DateAdd(Interval, Amount, yourDate)
DateAdd("ww", 2, now)
DateAdd("ww", -2, now)

' Value	        Description
' ============================
' yyyy		Year
' q	        Quarter
' m	        Month
' y	        Day of the year
' d	        Day
' w	        Weekday
' ww	        Week of a year
' h	        Hour
' n	        Minute
' s        	Second
' =========

' Search in string
' =========
foo = "12.34"
response.write(instr(foo, "."))
' Output: 3
' =========

' Cut string
' =========
response.write(left("1234567", 3))
' Output: 123
response.write(right("1234567", 3))
' Output: 567
response.write(mid("1234567", 3, 2))
' Output: 34
response.write(mid("1234567", 3))
' Output: 567
' =========

' String into float
' =========
String = "12,26"
Float = CDbl(String)
Result = Float + 7.74
' =========

' String into int
' =========
String = "12,26"
Int = CInt(String)
Result = Int + 7.74
' =========

' Split string
' =========
foo = "My-Name"
bar = split(foo, "-")
response.write(bar(0) & " " & bar(1))
' Output: My Name
' =========

' Replace' =========
foo = "My-Name"
response.write(replace(foo,"-"," "))
' Output: My Name
' =========

ASP 阵列是否相等

function areArraysEqual(byval array1, byval array2)
	areTheyEqual = true
	if ubound(array1) <> ubound(array2) then
		areTheyEqual = false
	else
		for i = 0 to ubound(array1)
			if (array1(i) <> array2(i)) then
				areTheyEqual = false
			end if
		next
	end if
	areArraysEqual = areTheyEqual
end function

ASP ASP Shuffle数组

'From http://www.4guysfromrolla.com/aspfaqs/ShowFAQ.asp?FAQID=114
Function Shuffle( inArray, needed )
    ' find out how many input elements there are...
    incnt = UBound( inArray )
    ' then create the output array to be the size
    ' requested via the "needed" argument
    dim outArray
    redim outArray( needed )

    ' now we will select the number of values
    ' specified as "needed"...
    For i = 0 To needed
        ' choose a random number from 1 to our
        ' current input array usage size...
        choose = Int( incnt * Rnd(1) ) 

        ' put that chosen element into the next
        ' slot in the output array...
        outArray( i ) = inArray( choose )
        
        ' here's the tricky part: Since we just
        ' used the "choose" element, we don't need
        ' it any more...we replace it with the last
        ' element of the in-use part of the array!
        inArray( choose ) = inArray( incnt )
        
        ' and then we (effectively) shrink the array!
        ' Next time through the loop, there will be
        ' one fewer elements in the array to choose
        ' from...because we have (effectively) deleted
        ' the one just chosen!
        incnt = incnt - 1

    Next
    ' return the shuffled output
    Shuffle = outArray
End Function

ASP 字符数

<%
'Counts number of occurrences of a certain char(s) in a string, returns number
Function CharCount(SourceString, CharsToFind)

LengthOfSourceString = Len(SourceString)
LengthOfCharsToFind = Len(CharsToFind)

If LengthOfCharsToFind >= LengthOfSourceString Then
    If LCase(CharsToFind) = LCase(SourceString) Then
        CharCount = 1
    Else
        CharCount = 0
    End If
    Exit Function
Else
    LoopLength = (LengthOfSourceString - LengthOfCharsToFind) + 1
    OccurrenseCounter = 0
    For i=1 to LoopLength
        CurrentSample = Mid(SourceString,i,LengthOfCharsToFind)
        If LCase(CurrentSample) = LCase(CharsToFind) Then
            OccurrenseCounter = OccurrenseCounter + 1
        Else
        End If
    Next
    CharCount = OccurrenseCounter
End If

End Function
%>