<% For i = 1 to 10 Response.write(i & " mod 5 = " & i mod 5 & "<br>") Next %> |
This little script will give the following output:
1 mod 5 = 1
2 mod 5 = 2
3 mod 5 = 3
4 mod 5 = 4
5 mod 5 = 0
6 mod 5 = 1
7 mod 5 = 2
8 mod 5 = 3
9 mod 5 = 4
10 mod 5 = 0
<%
For i = 1 to 10
If i mod 2 = 1 Then
Response.write(i & " is odd.<br>")
Else
Response.write(i & " is even.<br>")
End If
Next
%>
<%
Function isOdd(iInput)
IsOdd = CBool( iInput Mod 2 )
End Function
%>
<%
iCellsPerRow = 3
iItems = 9
' Create the table
strOutput = "<table>"
' Loop through all items
For i = 1 to iItems
' Check to see if this is the start of a new row
If i mod iCellsPerRow = 1 Then strOutput = strOutput & "<tr>"
' Add a cell for this item
strOutput = strOutput & "<td>" & i & "</td>"
' Check to see if this is the end of a row
If i mod iCellsPerRow = 0 Then strOutput = strOutput & "</tr>"
Next
' Close the table
strOutput = strOutput & "</table>"
' Write the HTML output
Response.write(strOutput)
%>
<%
iCellsPerRow = 3
iItems = 9
' Create the table
strOutput = "<table>"
' Loop through all items
For i = 1 to iItems
' Check to see if this is the start of a new row
If i mod iCellsPerRow = 1 Then strOutput = strOutput & "<tr>"
' Add a cell for this item
strOutput = strOutput & "<td>" & i & "</td>"
' Check to see if this is the end of a row
If i mod iCellsPerRow = 0 Then strOutput = strOutput & "</tr>"
Next
' If we're not at the end of a row,
' fill the rest of the row with empty cells.
If iItems mod iCellsPerRow > 0 Then
' Loop through to complete table
For j = 1 to iCellsPerRow - (iItems mod iCellsPerRow)
' Add an empty cell
strOutput = strOutput & "<td> </td>"
' Add a close row tag if this is the last cell.
If j = iCellsPerRow - (iItems mod iCellsPerRow) Then _
strOutput = strOutput & "</tr>"
Next
End if
' Close the table
strOutput = strOutput & "</table>"
' Write the HTML output
Response.write(strOutput)
%>
'asp' 카테고리의 다른 글
인증번호생성 함수 (0) | 2011.02.16 |
---|---|
Http Request 5 (0) | 2011.02.16 |
Classic ASP page template for VS 2005 (0) | 2011.01.28 |
Database Filtering injection (0) | 2010.12.29 |
배열을 이용한 InStr로 특정 문자 검색 (0) | 2010.12.29 |