×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Inputting Excel Tables into VB

Inputting Excel Tables into VB

Inputting Excel Tables into VB

(OP)
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

RE: Inputting Excel Tables into VB

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.

RE: Inputting Excel Tables into VB

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!

RE: Inputting Excel Tables into VB

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.

RE: Inputting Excel Tables into VB

(OP)
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.

RE: Inputting Excel Tables into VB

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources