Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inputting Excel Tables into VB

Status
Not open for further replies.

zuccus

Petroleum
Jun 19, 2003
137
I am writing a little application in Visual Studio Express and I want to import 5 colum wide x 400 row long data from excel and hard code it into the program as constants.

Is there a way to import this easily into VB?

The only idea I have come up with is to populate a column in the 6th column with the VB code and using the "&" to combine the data and then copy and paste it into the program.

Any other ideas? I am no expert on this VB stuff (Yet) so I am looking for simple ideas.

Thanks

Zuccus
 
Replies continue below

Recommended for you

The "copy and paste into the VB code as text" method sounds the simplest to me. You can use the Excel functions to concatenate, etc.

You can even use an Excel worksheet function like: = " dim " & cellreference & " as integer" to get the text you want, then copy and paste.
 
If I had to do that I would include an MDB with a table for the 'constants'. You can build an Access table from an Excel sheet quite easily. Your VB can then use the data without having to run Excel and can be used by people who do not have Access. A query can combine the columns any way you like.
And I would never hard code constants!
 
Or you can read in the data at run time. From the Excel worksheet itself or from a text file. Then store as pre-assigned variables. I don't like this approach myself, unless the data changes a lot.
 
I think I am going to follow FrancisL's option because that was also suggested to me by one of our IT guys. Basically I am trying to hide the data from the average user so it can't be changed.

If it can be used by people without access than I should be pretty well off. I don't like hard coding constants either, but I didn't have any ideas about how to get it out of excel.

Thanks Tom and FrancisL.
 
I think you have made a good choice, let us know if you want any assistance.
A VB form wizard should produce a quick way to edit the data for those that need to.
Amd think about testing too, a set of test data in another table perhaps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor