日期:2011-05-02  浏览次数:21056 次

这是一个模拟股票滚屏的看板程序,程序将10个股票的价格和张跌幅信息以每次5组的方式显示,循环交替,不同以往滚屏尾部留有空白的情况。由于代码简单,这里就不对其多加注释了。

<html>
<head>
<!-- sunboy008@sina.com.cn -->
<script LANGUAGE="VBScript">
<!--
dim j,arry1(10),arry2(10),arry3(10),arry4(10)

'分别定义滚动子段的数组

arry1(0)="数码科技"
arry1(1)="太子网络"
arry1(2)="小邦会社"
arry1(3)="正大集团"
arry1(4)="聚友网络"
arry1(5)="全向科技"
arry1(6)="清华紫光"
arry1(7)="同创科技"
arry1(8)="中关村"
arry1(9)="TCL电子"

arry2(0)="12.56"
arry2(1)="56.50"
arry2(2)="5.54"
arry2(3)="23.11"
arry2(4)="16.70"
arry2(5)="14.00"
arry2(6)="9.20"
arry2(7)="12.30"
arry2(8)="87.56"
arry2(9)="12.30"


arry3(0)="12.10"
arry3(1)="55.70"
arry3(2)="5.36"
arry3(3)="22.80"
arry3(4)="16.50"
arry3(5)="13.60"
arry3(6)="9.20"
arry3(7)="12.89"
arry3(8)="88.00"
arry3(9)="12.56"


arry4(0)="6.2%"
arry4(1)="-5%"
arry4(2)="1.2%"
arry4(3)="8%"
arry4(4)="-5.6%"
arry4(5)="3%"
arry4(6)="-3%"
arry4(7)="4%"
arry4(8)="-2.2%"
arry4(9)="-6.3%"

'滚动程序
Sub toplay()
  j=j+1

  for i=0 to 4
      a(i).innerhtml=show1(j-1+i)
      b(i).innerhtml=show2(j-1+i)
      c(i).innerhtml=show3(j-1+i)
      d(i).innerhtml=show4(j-1+i)
  next

  if j>9 then j=0
  settimeout "toplay",2000
end sub

function show1(num)
  if num=>10 then
     show1=arry1(num-10)
  else
     show1=arry1(num)
  end if
end function

function show2(num)
  if num=>10 then
     show2=arry2(num-10)
  else
     show2=arry2(num)
  end if
end function

function show3(num)
  if num=>10 then
     show3=arry3(num-10)
  else
     show3=arry3(num)
  end if
end function

function show4(num)
  if num=>10 then
     show4=arry4(num-10)
  else
     show4=arry4(num)
  end if
end function
-->
</script>
<style>
<!--
td { font-size:9pt }
-->
</style>
</head>

<body >

<table border="0" cellpadding="5" cellspacing="1">
  <tr>
    <td bgcolor="#FFCC66">证券名称</td>
    <td bgcolor="#FFCC66">成交</td>
    <td bgcolor="#FFCC66">开盘</td>
    <td bgcolor="#FFCC66">涨跌</td>
  </tr>
<%
for i=0 to 4
  dim bg
  bg="F0EDE6"
  if i mod 2=0 then bg="D2E0F0"
%>
  <tr>
    <td id="a" bgcolor=<%=bg%> align="right"></td>
    <td id="b" bgcolor=<%=bg%> align="right"></td>
    <td id="c" bgcolor=<%=bg%> align="right"></td>
    <td id="d" bgcolor=<%=bg%> align="right"></td>
  </tr>
<%next%>
</table>

</body>

</html>

注:你可以更改其中的每组显示股票的行数,这里设置的是5个。