asp 自學總結 [1]

來源:互聯網
上載者:User

<%@ 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
%>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.