主题:  请教在asp中一段vbscript的代码

zt

职务:普通成员
等级:1
金币:1.0
发贴:229
注册:2002/10/10 10:26:38
#12003/12/4 15:26:25
代码如下:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/fbook.asp" -->
<%
Dim Recordset1
Dim Recordset1_numRows

Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_fbook_STRING
Recordset1.Source = "SELECT * FROM f_bbs"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()

Recordset1_numRows = 0
%>
<%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = 3
Repeat1__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat1__numRows
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<link href="1.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="75%" border="1" cellpadding="2" cellspacing="0" class="px12">
<tr bgcolor="#FF9900">
<td width="25%">姓名</td>
<td width="25%">QQ</td>
<td width="25%">HOMEPAGE</td>
<td>
<p>CONTENT</p></td>
</tr>
<% If Not Recordset1.EOF Or Not Recordset1.BOF Then %>
<%
While ((Repeat1__numRows <> 0) AND (NOT Recordset1.EOF))
%>
<%If (Repeat1_numRows Mod 2) Then %>
<tr bgcolor="#FFFF99">
<%Else%>
<tr bgcolor="#FFFFFF">
<%End If%>




<td><%=(Recordset1.Fields.Item("f_name").value)%></td>
<td><%=(Recordset1.Fields.Item("f_qq").value)%></td>
<td><%=(Recordset1.Fields.Item("f_homepage").value)%></td>
<td><%=(Recordset1.Fields.Item("f_content").value)%></td>
</tr>
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
Recordset1.MoveNext()
Wend
%>
<% End If ' end Not Recordset1.EOF Or NOT Recordset1.BOF %>
</table>
</body>
</html>
<%
Recordset1.Close()
Set Recordset1 = Nothing
%>
=====================================
加色代码目的是让它隔行显示颜色。但是不知错在哪里,请指教。



janlay

职务:管理员
等级:7
金币:28.0
发贴:7244
注册:2003/11/27 18:07:11
#22003/12/4 20:20:57
这段代码本身没有错误,vbscript会将表达式的值转换为布尔值来判断。

变量命名程序逻辑感觉莫名其妙,把出错信息贴出来看看