注册 登录
编程论坛 ASP技术论坛

vbscript中的CreatObject("Scripting.Dictionaty")问题

zmhdxy 发布于 2008-02-27 13:47, 1258 次点击
一个 它是干什么的,有什么用
二个下面一段代码那里错了,
望高手们帮忙了
<html><head><title>for each....next语句</title>
<script language="vbscript">
Sub cmdChange_OnClick
set Obj=CreatObject("Scripting.Dictionaty")
Obj.Add "0","文本1"
Obj.Add "1","文本2"
Obj.Add "2","文本3"
j=0
for each i in Obj
document.textForm.Elements(j).value=Obj.Item(i)
j=j+1
next
end sub
</script></head>
<body><div align =center >
<form name="textForm">
<input type="text "><br>
<input type="text "><br>
<input type="text "><br>
<input type="button" name="cmdChange" value ="单击此处">
</form>
</div>
</body></html>
4 回复
#2
zmhdxy2008-02-27 22:06
人呢 高手呢 难道放假了
那我怎么办
不会是凉拌吧
#3
zmhdxy2008-02-28 23:20
这个就没人会吗
大家帮帮忙吗
#4
Kettyjin19832008-02-29 09:06
Dictionary是Scripting的对象,相当于数组,
Obj.Add "0","文本1"-----向Dictionary添加键和项目对...
该程序是:当点击按钮时,文本框里的值变成了文本1,文本2,文本3
错误的地方是:set Obj=CreatObject("Scripting.Dictionaty")
改成set Obj = CreateObject("Scripting.Dictionary")
#5
zmhdxy2008-03-01 12:02
你是对的
正确的前台代码
<html><head><title>For Each ... Next语句</title></head>
<script language="VBScript">
Sub cmdChange_OnClick
    Set Obj = CreateObject("Scripting.Dictionary")
    Obj.Add "0","文本1"     '添加键和项目
    Obj.Add "1","文本2"
    Obj.Add "2","文本3"
    '将对象Obj各项目的值赋予各文本框
    j=0
    For Each i in Obj
        Document.textForm.Elements(j).Value = Obj.Item(i)
        j=j+1
    Next
End Sub
  </script></head>
  <body><center><form name="textForm"><input type = "Text"><p>
  <input type = "Text"><p><input type = "Text"><p>
  <input type = "Button" name="cmdChange" value="单击此处"><p>
  </form></center></body></html>
1