[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 530
  • Last Modified:

Programmatically change a variable Name


Here is what I'm trying to do.

I have a list of tags in an array downloaded from another source.  I wish to take this array of items and put them in a data table.  This data table will be saved as an ACCESS database.

The brute force method which works is given below.

I would just go with that other than the tag array is not always the same size which means more coding.   It seems there should be a way to  add the # to tag# at the end of each currentrow in some type of code.   Easy to do if its a string or array, but not a specific row object linked to a row in a database.  Ideas to solve this ?


For I = 0 To listReturn.Count - 1
   Dim currentrow As EtsyDataSet.EtsyListingRow = Etsydata.EtsyListing.NewEtsyListingRow

 currentrow.tag1 = listReturn(I).tags(1).ToString
 currentrow.tag2 = listReturn(I).tags(2).ToString
 currentrow.tag3 = listReturn(I).tags(3).ToString
 currentrow.tag4 = listReturn(I).tags(4).ToString
 currentrow.tag5 = listReturn(I).tags(5).ToString
 currentrow.tag6 = listReturn(I).tags(6).ToString
  currentrow.tag12 = listReturn(I).tags(12).ToString

 Etsydata.EtsyListing.AddEtsyListingRow(currentrow)

Open in new window

0
Zimbug4
Asked:
Zimbug4
  • 2
  • 2
  • 2
1 Solution
 
rockiroadsCommented:
Im not familiar with EtsyDataSet but taking a educated guess

does the listing row show something like Field or Itrem?

eg

currentrow.Item("tag1")

would the above work?
if so then maybe a count like this

for i in 1 to 6
    currentrow.Item("tag" & i) = listReturn(I).tags(i).tostring


see if there is any property like that
0
 
rfportillaCommented:
0
 
rfportillaCommented:
I think Rockiroads has the right idea.   It depends on what the object will support, but you can create "dynamic" variable names in an associative array using strings.  I think this is what you are looking for...
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Zimbug4Author Commented:
Rockiroads educated guess was correct.  The use of item worked.
I've added below what worked based on the suggestion
For Each item In listReturn(I).tags
    cnt = cnt + 1
    currentrow.Item("tag" & cnt.ToString) = listReturn(I).tags(cnt - 1).ToString
   Next

Open in new window

0
 
Zimbug4Author Commented:
Thanks!  I knew there had to a lot easier way than the way what I was approaching it.
0
 
rockiroadsCommented:
Cool. Nice educated guess then :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now