For i = 1 To... Dim var(i)

Posted by Carpenter under Regular Expressions on 11/16/2009 | Views : 1487 | Status : [Member] | Replies : 2
Hi all

I am looking for some help on the below code - the problem is that I just don't know how to dim up a variable name that needs a variable added to it's end... Any help?

For i = 1 To Count

' Dim image_var(i) As String ' I need the variable "image_var(i)" here to vary with the loop's value of i
Dim image_var(i) As New LinkedResource(Server.MapPath(myArray(0)))
' need also to add 1 to the 0 in myArray(0), after each go through the loop

image_var(i).ContentId = "imageContentId_" + i.ToString

htmlView.LinkedResources.Add(image_var(i))
Next i




Responses

Posted by: Vuyiswamb on: 11/17/2009 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
i have not done vb in long time. i sometimes get lost while looking at vb code. i took your code and paste it on this side

http://converter.telerik.com/

and convert it to c# and it gave me this

for (i = 1; i <= Count; i++)
{

// Dim image_var(i) As String ' I need the variable "image_var(i)" here to vary with the loop's value of i
LinkedResource image_var = new LinkedResource(Server.MapPath(myArray(0)));
// need also to add 1 to the 0 in myArray(0), after each go through the loop

image_var(i).ContentId = "imageContentId_" + i.ToString;

htmlView.LinkedResources.Add(image_var(i));
}


then it was like pure English to me again, I would like you to provide more info so that i can help you. What is it is your Problem and what are you trying to achieve.

Thank you for posting at dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Carpenter, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Carpenter on: 11/17/2009 [Member] Starter

Up
0
Down
Hi

First of all that looks a very good and useful link (http://converter.telerik.com/) to have, thanks for that...


My probem was that I though that I needed a variable variable-name (image I though needed to vary)- in the below:

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 b


But I needn't after all... the above ended up working for me.


Could you tell me though, if that logic make any sence to you - that I needed a "variable vairable-name in the above"...






Carpenter, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response