<%@ language=JScript%> 標識你的ASP代碼用什麼指令碼語言
ASP中可以寫 VB也可寫JS隨你喜好,以下主要為vb
指令碼語言:javascript 和 vbscript 都為指令碼語言,如果,標識<%@ language= %>
則為IIS預設的指令碼語言。
變數的聲明用Dim public private
<%Dim i,k%> 如果不聲明 預設為隱式聲明
運算子--算術運算子
- * / \(整除) Mod + - &(字串的串連)
運算子--比較子
= <>(不等) < > <= >=
運算子--比較子
NOT AND OR (與或非)
IF語句
<%
if a>12 then
response.write "11111"
else
response.write "2222"
end if
%>
for迴圈
<%
for j=1 to 10
response.write "me"
next
%>
now() 目前時間
常量的定義:(const)
數字:const s=6
字串:const s="gg"
時間:const #2009-01-12#
條件陳述式(if..then..else select case)
<%
if a<5 then
response.write "111"
elseif a<10 then
response.write "222"
else
response.write "333"
end if
%>
<%
dim a
a=10
select case a
case 1,2,3,4
response.write "1"
case 5,6,7,8
response.write "2"
case 9,10
response.write "3"
%>
迴圈語句
do...loop 條件為真迴圈
while...wend 條件為真迴圈
for...next 指定迴圈次數
foreach...next 對數組或集合進行迴圈
第一種:相當於C中while迴圈
<%
do while
....
loop
%>
第二種:相當於C中do...while迴圈
<%
do
....
loop while
%>
例子:
<%
do while a<10
response.write "aaaa"
a = a+1
loop
%>
<%
for i=1 to 10 step 2 //step步長為2
response.write "ddd<br>"
next
%>
過程(函數)
sub/function 區別在於sub無傳回值,而function有傳回值
定義:
sub a()
msgbox "haha"
end sub
調用 call a()
sub mm(a,b)
msgbox (a&b)
end sub
調用 call a("dd","cc")
<%
function a()
....
end function
%>