我在寻找帮助,试图在for循环中更改变量名:
For b = 1 To Count
' the below image_var(b) varible needs to vary on each iteration'
Dim image_var(b) As New LinkedResource(Server.MapPath(myArray(b-1)))
' need also to have the b in myArray(b-1) bit work through the loop too'
' that is I''m after the array index b minus 1'
image_var(b).ContentId = "imageContentId_" + b.ToString
' add the LinkedResource to the appropriate view'
htmlView.LinkedResources.Add(image_var(b))
Next b谢谢,因为我不能登录来接受一个答案.
谢谢,古法-我的照片现在正在通过电子邮件和出现。
image_var(b)中的(b)对我来说也只是一个存根--直到我找到了我想要的代码.我是新来的,甚至不知道/意识到它做了一个数组.我很势利。
再次感谢..。
发布于 2009-11-16 14:14:03
我不知道为什么您认为每个实例都需要一个单独的变量。变量只保存对对象的引用,不管您如何称呼该变量。您只需对每个对象重用相同的变量:
For b = 1 To Count
Dim image As New LinkedResource(Server.MapPath(myArray(b-1)))
image.ContentId = "imageContentId_" + b.ToString
' add the LinkedResource to the appropriate view'
htmlView.LinkedResources.Add(image)
Next bhttps://stackoverflow.com/questions/1742259
复制相似问题