Hi, im looking for some advice/guidance with regard to visual basic. Im and final year engineering student and my project requires me to make a graphical user inter phase to teach aerodynamics. I need to find out how to link the programme i design through VB with excel. Then the user can input their own data into the programme and excel will use this to make a graph and input the graph into the programme. Kind of like working in the background and producing the graph in the user inter phase. Sorry for the prolonged explanation but i've very limited computer and visual basic knowledge so its quiet confusing for me to explain. Could u tell me if this is possible and where i could find the information to teach me how to do this? Thank you, your help would be very much appreciated. Is the question above you already answered the same thing? it sounds similar but i dont understand the computer language! Sorry

Recommended Answers

All 6 Replies

Im getting the following error messages

Error 1 'aTemp' is not declared. It may be inaccessible due to its protection
Error 2 Array lower bounds can be only '0'.
Error 3 Conversion from 'Date' to 'Double' requires calling the 'Date.ToOADate' method.
Error 4 'aTemp' is not declared. It may be inaccessible due to its protection level.
Error 5 'aTemp' is not declared. It may be inaccessible due to its protection level.

here's the working example from the microsoft website. Use it as a starting point to do whatever you need to do with Excel ..

Article ID: 142387 - Last Review: June 30, 2004 - Revision: 4.3
How To Create Excel Chart w/OLE Automation from Visual Basic
=============
Steps to Create Example Program

Start a new project in Visual Basic. Form1 is created by default.
Add a command button (Command1) to Form1.
Add the following code to the Command1_Click event procedure:

Private Sub Command1_Click()
       
        Dim oXL As Object        ' Excel application
        Dim oBook As Object      ' Excel workbook
        Dim oSheet As Object     ' Excel Worksheet
        Dim oChart As Object     ' Excel Chart
        
        Dim iRow As Integer      ' Index variable for the current Row
        Dim iCol As Integer      ' Index variable for the current Row
        
        Const cNumCols = 10      ' Number of points in each Series
        Const cNumRows = 2       ' Number of Series

        
        ReDim aTemp(1 To cNumRows, 1 To cNumCols)
        
        'Start Excel and create a new workbook
        Set oXL = CreateObject("Excel.application")
        Set oBook = oXL.Workbooks.Add
        Set oSheet = oBook.Worksheets.Item(1)
        
        ' Insert Random data into Cells for the two Series:
        Randomize Now()
        For iRow = 1 To cNumRows
           For iCol = 1 To cNumCols
              aTemp(iRow, iCol) = Int(Rnd * 50) + 1
           Next iCol
        Next iRow
        oSheet.Range("A1").Resize(cNumRows, cNumCols).Value = aTemp
        
        'Add a chart object to the first worksheet
        Set oChart = oSheet.ChartObjects.Add(50, 40, 300, 200).Chart
        oChart.SetSourceData Source:=oSheet.Range("A1").Resize(cNumRows, cNumCols)

        ' Make Excel Visible:
        oXL.Visible = True

        oXL.UserControl = True
            
    End Sub

=============

Tried that, cant get it to work. Im using vb 2010 express. Would that make a difference, it doesnt seem to recognise those atemp commands

I tried vb 2010 express once and immediately went back to vb6. The example above from microsoft is a vb6 project.


'atemp' is not a vb command.

I think you should look for an example that uses vb2010. A quick google search got me this on the msdn website - http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/487fb2d5-92fd-43f8-8ecd-35e03cf98d49/

It looks almost like the vb6 example ..

You can also look here for vb 2010 code at msdn - http://msdn.microsoft.com/en-us/vbasic/ms789074

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.