懂得ASP或VB的进

来源:百度知道 编辑:UC知道 时间:2024/05/22 19:05:23
这是写在ASP里面的一段代码

<% dim sname
sname="magic"
response.write(sname)
sub print()
dim sname
sname="showip"
response.write(sname)
end sub

sub print2()
dim sname
sname="xilan"
response.write(sname)
end sub
print
call print2()
response.write(sname)

%>

什么意思,老师只呼呼的讲解,然后输出来magicshoipxilanmagic
。。。

第三行输出了赋值的变量 magic print 就输出了showip call print2()
输出了xilan 最后再输出 magic 最终结果就是你看到的喽

dim sname
sname="magic"
response.write(sname) 在页面运行时 ,输出magic

定义一个方法 输出showip
sub print()
dim sname
sname="showip"
response.write(sname)
end sub

定义一个方法 输出xilan
sub print2()
dim sname
sname="xilan"
response.write(sname)
end sub

print 方法1 ,输出showip
call print2() 方法1 ,输出xilan
response.write(sname) 上面定义sname="magic" ,再次输出

页面运行 方法1 方法2 页面运行定义的sname
magic shoip xilan magic

你们的老师估计也不怎么样

这个程序的输出分四部分

1 、 response.write(sname) 这是第三句,sname为全局变量, 变更值sname="magic"

2、 print 是倒数第三句,调用了子函数print() ,在这个子函数里 sname="showip" 把sname这个变量赋值 showip ,然后输出用的语句是 response.write(sname)

3、call print2() ,调用函数print2() ,把sname 这个变更赋值xilan ,然后输出用的语句是 response.