+ -
当前位置:首页 → 问答吧 → request.form("shuliang"&h)的类型为什么是istringlist类型?

request.form("shuliang"&h)的类型为什么是istringlist类型?

时间:2011-06-27

来源:互联网

如题,在我的ASP程序中有一个添加操作,主要代码如下,其中红色部分是当时用于检测数类型和值的。真正程序是没有红色部分的。
红色检测的结果:typename(request.Form("shuliang"&h))&"<br/>")为IStringlist,
我还检测了下值,其中值只有一个,是h=1时对应的值,是我预期的。
我查了资料Istringlist是一个对象,不能添加值的。
所以我想问一下为什么request.from("shuliang"&h)会是Istringlist对象呢?如何才能添加成功了?谢谢帮忙!
VBScript code

    Set RBJZycl = Server.CreateObject("ADODB.Recordset") 
    SQLRBJZycl = "Select * From jzycl where [name] is null" 
    RBJZycl.Open SQLRBJZycl,connstr,1,3 
    RBJZycl.AddNew
    for h=1 to 6
        if request.Form("clname"&h)<>"" then
            RBJZycl("name")=request.Form("clname"&h)
            RBJZycl("jixing")=request.Form("jixing"&h)
            [color=#FF0000]response.Write(typename(request.Form("shuliang"&h))&"<br/>")
            response.Write(h&"<br/>"&request.Form("shuliang"&h)&"<br/>")
            response.End[/color]            RBJZycl("shuliang")=FormatNumber(request.Form("shuliang"&h))
            RBJZycl("riqi")=request.Form("riqi"&h)
            RBJZycl.update
        end if
    next
    RBJZycl.close
    set RBJZycl=nothing


作者: feilong5xian   发布时间: 2011-06-27

其中这一段是红色的,没有标记成功!
response.Write(typename(request.Form("shuliang"&h))&"<br/>")
response.Write(h&"<br/>"&request.Form("shuliang"&h)&"<br/>")
response.End

作者: feilong5xian   发布时间: 2011-06-27

dim str 
For Each s In request.Form("shuliang"&h))
str = str + s+","
Next

循环看看

作者: aspwebchh   发布时间: 2011-06-27

,类似于集合,这时要用Set赋值。所以在赋值之前要判断Request.Form("industrytype")的子类型,如:
JScript code

If TypeName(Request.Form("shuliang"&h)) = "IStringList" Then
   Set shuliang=Request.Form("shuliang"&h)
Else
   shuliang=Request.Form("shuliang"&h)
End If

作者: showbo   发布时间: 2011-06-27

当Request.Form("industrytype")存在多个值时,它就不是String了,而是一种叫做IStringList的对象,类似于集合,这时要用Set赋值。所以在赋值之前要判断Request.Form("industrytype")的子类型

作者: showbo   发布时间: 2011-06-27

引用 2 楼 aspwebchh 的回复:
dim str
For Each s In request.Form("shuliang"&amp;h))
str = str + s+","
Next

循环看看

我把这个加入到RBJZycl("jixing")=request.Form("jixing"&h)这个后面。
提示语句未结束。

引用 4 楼 showbo 的回复:
当Request.Form("industrytype")存在多个值时,它就不是String了,而是一种叫做IStringList的对象,类似于集合,这时要用Set赋值。所以在赋值之前要判断Request.Form("industrytype")的子类型

这个我也在http://hi.baidu.com/dongfangjunzi/blog/item/27ca85caa331988cc81768bc.html看到了,但是联系不到如何解决问题。

作者: feilong5xian   发布时间: 2011-06-27

谢谢两位的回答
最后在RBJZycl("jixing")=request.Form("jixing"&h)
后面加入一下代码就可以了。
VBScript code
If TypeName(Request.Form("shuliang"&h)) = "IStringList" Then
                   Set industrytype=Request.Form("shuliang"&h)
                   shuliang=industrytype(1)
                Else
                   shuliang=Request.Form("shuliang"&h)
                End If
                if isNumeric(trim(shuliang))=true then
                TJshuliang=shuliang
                end if

作者: feilong5xian   发布时间: 2011-06-27