动态变量

编程入门 行业动态 更新时间:2024-10-22 14:39:29
本文介绍了动态变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

循环记录集时有没有办法创建动态变量? 例如下面的第一个循环之后我会得到myVarA1和myVarB1,之后是 第二个循环,我会得到myVarA2和myVarB2。 代码************************ *********** set objRS = GetMyRecordSet() i = 1 objRS.MoveFirst Do not not objRS.EOF " myVarA" &安培; i = objRS(0) " myVarB" &安培; i = objRS(1) i = i + 1 objRS.MoveNext() 循环

Is there a way to create dynamic variables when looping through a recordset? For example below, after the 1st loop I''d have myVarA1 and myVarB1, after 2nd loop, I''d get myVarA2 and myVarB2. CODE *********************************** set objRS = GetMyRecordSet() i=1 objRS.MoveFirst Do While Not objRS.EOF "myVarA" & i = objRS(0) "myVarB" & i = objRS(1) i = i + 1 objRS.MoveNext() Loop

推荐答案

scott写道: 有没有办法创建动态变量 有(vbscript Execute语句),但不建议这样做。使用 数组。 循环浏览记录集时?例如下面,在第一个循环之后我会有myVarA1和 myVarB1,在第二个循环后,我会得到myVarA2和myVarB2。 Is there a way to create dynamic variables There is (the vbscript Execute statement), but it''s not recommended. Use an array. when looping through a recordset? For example below, after the 1st loop I''d have myVarA1 and myVarB1, after 2nd loop, I''d get myVarA2 and myVarB2.

使用记录集,GetRows数组似乎非常适合您的目的 Dim arData 如果不是objRS.EOF则arData = objRS.GetRows(,, Array( 0,1)) objRS.Close:设置objRS = Nothing VarA1对应arData(0,0) VarB1对应arData(1,0) VarA2对应arData(0,1) VarB2对应arData(1,1) - Microsoft MVP - ASP / ASP.NET 请回复新闻组。我的From 标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。

With a recordset, a GetRows array seems ideal for your purpose Dim arData if not objRS.EOF then arData=objRS.GetRows(,,Array(0,1)) objRS.Close: Set objRS = Nothing VarA1 would correspond to arData(0,0) VarB1 would correspond to arData(1,0) VarA2 would correspond to arData(0,1) VarB2 would correspond to arData(1,1) -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don''t check it very often. You will get a quicker response by posting to the newsgroup.

谢谢,但我仍然有问题。怎么能动态创建说VarA1,VarA2,VarA3 而无需硬编码?我研究并发现了一种redim方法, 但很困惑。 " Bob Barrows [MVP]" <再****** @ NOyahoo.SPAMcom>在消息中写道 新闻:uD ************** @ TK2MSFTNGP10.phx.gbl ... Thanks, but I still have a problem. How can create say VarA1, VarA2, VarA3 dynamically without hardcoding them? I researched and found a redim method, but was confused. "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:uD**************@TK2MSFTNGP10.phx.gbl... scott写道: 有没有办法创建动态变量 Is there a way to create dynamic variables

有(vbscript Execute语句),但不建议这样做。使用数组。

There is (the vbscript Execute statement), but it''s not recommended. Use an array.

在循环记录集时?例如下面,在第一个循环之后我会有myVarA1和 myVarB1,在第二个循环之后,我会得到myVarA2和myVarB2。 when looping through a recordset? For example below, after the 1st loop I''d have myVarA1 and myVarB1, after 2nd loop, I''d get myVarA2 and myVarB2.

使用记录集,一个GetRows数组看起来很适合你的目的 如果不是objRS.EOF那么昏暗arData 然后arData = objRS.GetRows(,,数组(0,1)) objRS.Close :设置objRS = Nothing VarA1对应arData(0,0) VarB1对应arData(1,0) VarA2对应arData(0,1) ) VarB2对应arData(1,1) - Microsoft MVP - ASP / ASP.NET 请回复新闻组。我的From 标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将得到更快的回复。

With a recordset, a GetRows array seems ideal for your purpose Dim arData if not objRS.EOF then arData=objRS.GetRows(,,Array(0,1)) objRS.Close: Set objRS = Nothing VarA1 would correspond to arData(0,0) VarB1 would correspond to arData(1,0) VarA2 would correspond to arData(0,1) VarB2 would correspond to arData(1,1) -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don''t check it very often. You will get a quicker response by posting to the newsgroup.

您不会:使用数组代替动态变量。 而不是VarA1,使用arData(0,0)。 而不是VarB2,使用arData(1,1) Bob Barrows scott写道: You don''t: use the array instead of the dynamic variables. Instead of VarA1, use arData(0,0). Instead of VarB2, use arData(1,1) Bob Barrows scott wrote: 谢谢,但我还是有问题。怎么能动态创建VarA1,VarA2, VarA3而不用硬编码呢?我研究并发现了一种 redim方法,但很困惑。 Bob Barrows [MVP]" <再****** @ NOyahoo.SPAMcom>在消息中写道新闻:uD ************** @ TK2MSFTNGP10.phx.gbl ... Thanks, but I still have a problem. How can create say VarA1, VarA2, VarA3 dynamically without hardcoding them? I researched and found a redim method, but was confused. "Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message news:uD**************@TK2MSFTNGP10.phx.gbl... scott写道: 有没有办法创建动态变量 Is there a way to create dynamic variables

有(vbscript Execute语句),但不推荐。使用数组。

There is (the vbscript Execute statement), but it''s not recommended. Use an array.

在循环播放记录集时?例如下面,在第一个循环之后,我将拥有myVarA1 和myVarB1,在第二个循环之后,我将获得myVarA2和myVarB2。 when looping through a recordset? For example below, after the 1st loop I''d have myVarA1 and myVarB1, after 2nd loop, I''d get myVarA2 and myVarB2.

使用记录集,一个GetRows数组看起来很适合你的目的 如果不是objRS.EOF那么昏暗arData 然后arData = objRS.GetRows(,,数组(0,1)) objRS.Close :设置objRS = Nothing VarA1对应arData(0,0) VarB1对应arData(1,0) VarA2对应arData(0,1) ) VarB2对应arData(1,1) - Microsoft MVP - ASP / ASP.NET 请回复新闻组。我的From 标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。

With a recordset, a GetRows array seems ideal for your purpose Dim arData if not objRS.EOF then arData=objRS.GetRows(,,Array(0,1)) objRS.Close: Set objRS = Nothing VarA1 would correspond to arData(0,0) VarB1 would correspond to arData(1,0) VarA2 would correspond to arData(0,1) VarB2 would correspond to arData(1,1) -- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don''t check it very often. You will get a quicker response by posting to the newsgroup.

- Microsoft MVP - ASP / ASP.NET 请回复新闻组。我的From 标题中列出的电子邮件帐户是我的垃圾邮件陷阱,因此我不经常检查它。通过发布到新闻组,您将获得更快的回复。

-- Microsoft MVP -- ASP/ASP.NET Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don''t check it very often. You will get a quicker response by posting to the newsgroup.

更多推荐

动态变量

本文发布于:2023-11-28 07:24:24,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641459.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:变量   动态

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!