Advertisement

03.07.2008 at 12:13PM PST, ID: 23223955
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.8

Reading data from Excel file into Visual Basic

Asked by SupermanTB in Visual Basic Programming

First, I'm brand new to visual basic.  I used to program quite a bit in Java, but it's been a few years.  I recently downloaded and installed Microsoft Visual Basic 2008 Express Edition and have just started programming.  At any rate, I'm trying to learn my way around visual basic by creating a program to read and display some data from an excel spread sheet into a simple form.  Eventually I hope to use the data in the excel spreadsheet in my program to do some data analysis in Visual Basic.  For now, I'm just trying to read and display one cell of data from the  excel spreadsheet.  I've looked at a few PAQ and was trying to get the following question to work.

http://www.experts-exchange.com/Programming/Misc/Q_20451935.html?sfQueryTermInfo=1+basic+excel+file+read+visual

I followed the instruction in the PAQ, but get the following error (Reference to a non-shared member requires an object reference).  The line of code that is causing the problem is with the Excel.Workbooks.Open underlined.

objWorkbook = Excel.Workbooks.Open("c:\goog.xls")

Again, I'm very new to Visual Basic, but I noticed that the code from the PAQ had a Set in front of that line.  Visual Basic 2008 Express Edition would not allow me to type in Set w/ out automatically making it SetAttr.  I'm not sure if the code written in the PAQ was from an older version of VB and maybe they got rid of the Set in the version I'm using?  I just thought I'd mention.

Any help would be greatly appreciated.  If you all have any advice on what would be the best way for me to work with the data in the Excel spreadsheet, that would be great.  I'm trying to figure out if it would be easier to grab the data straight from the spreadsheet or if it is possible to import the entire spreadsheet into some sort of data object in VB and work with that?  I would appreciate any guidance.  Thanks.  I'm attaching my code below as well.


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       
        Dim objWorkbook As Excel.Workbook
        Dim ObjWorksheet As Excel.Worksheet
        Dim objCell As Object

        Dim sData As String
        Dim iRow As Long
        Dim iCol As Long

        objWorkbook = Excel.Workbooks.Open("c:\goog.xls")
        ObjWorksheet = objWorkbook.Worksheets(1)

        sData = ObjWorksheet.Cells(1, 1).value

        TextBox4.Text = sData

    End SubStart Free Trial
[+][-]03.07.2008 at 03:08PM PST, ID: 21074927

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.07.2008 at 04:09PM PST, ID: 21075170

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.07.2008 at 04:47PM PST, ID: 21075323

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03.07.2008 at 04:55PM PST, ID: 21075348

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.13.2008 at 01:28PM PDT, ID: 21120514

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]03.19.2008 at 07:04PM PDT, ID: 21167610

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.12.2008 at 12:15PM PDT, ID: 21990097

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Sign Up Now!
Solution Provided By: pigparent
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.14.2008 at 06:25AM PDT, ID: 21997791

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.14.2008 at 06:31AM PDT, ID: 21997846

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20081112-EE-VQP-42 / EE_QW_2_20070628