Solved

Programmatically change a variable Name

Posted on 2010-09-16
6
519 Views
Last Modified: 2012-05-10

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
Comment
Question by:Zimbug4
  • 2
  • 2
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
ID: 33697954
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
 
LVL 9

Expert Comment

by:rfportilla
ID: 33697957
0
 
LVL 9

Expert Comment

by:rfportilla
ID: 33697987
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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:Zimbug4
ID: 33709630
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
 

Author Closing Comment

by:Zimbug4
ID: 33709633
Thanks!  I knew there had to a lot easier way than the way what I was approaching it.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33710106
Cool. Nice educated guess then :)
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now