Use Project Add Reference, then click the COM tab and add the Microsoft Excel 10.0 Object Library (yours might be 9.0 or some other version number).
As you probably realize by now, if you've read this chapter, your first job when accessing Excel objects is to declare an application object:
Dim exl As New Excel.Application
Then you contact the primary unit of organization in Excel, the range object (which can be as small as a single cell or as large as a worksheet). The remaining sections describe how to use handy features of Microsoft Excel in your VB.NET programs.
One useful feature that Excel has to offer us VB.NET programmers is its ability to evaluate mathematical expressions. Given that VB.NET includes lots of math functions, such as SIN, COS, and so on (if you first Imports System.Math), why would you need to use Excel? For one thing, Excel allows you to submit a string for evaluation, thereby making it relatively simple to permit users to enter expressions into your application and have them evaluated.
Listing 4.14 shows how you can calculate a SIN in VB.NET, while Listing 4.15 is an example that uses Excel to evaluate the same expression.
LISTING 4.14: EVALUATING MATH EXPRESSIONS IN VB.NET
LISTING 4.15: EVALUATING MATH EXPRESSIONS IN EXCEL
Private Sub Form1_Load(ByVal sender As System.Object, _