![]() |
How to use ActiveX in Excel | |
![]() Let UltimaSerial unleash the power of your Windaq Starter kit!
Lessons on how to use UltimaSerial
|
The following is a step-by-step lesson on how to use ActiveX in Visual C++ (VC++) In this lession, we will use Ultimaserial ActiveX to develop a data acquisition application with DATAQ's Starter kit. This sample will acquire data once per second from channel 1 of DI-158 and fill up the first twenty rows of the first column of the spreadsheet continuously. Once you understand this simple program, you can take a closer look at more Excel samples. Note: In this example, instead of embedding all the controls and codes in the spreadsheet directly, I use a form to collect all these so that it acts similar to the other Excel samples. Before we start, please download and install UltimaSerial then run Microsoft Excel. 1) Follow Tool->Macro->Visual BASIC Editor, and you should enter Microsoft Visual Basic Editor:
2) In the VB Editor, follow Insert->UserForm, and you should see this:
3) Move the mouse cursor to ToolBox. Click the right-button on the mouse and follow Additional Controls ...
4) In the Additional Controls dialogue box, select UltimaSerial Control and Timer Object , and hit OK to bring the two controls into the ToolBox. If you don't see these two controls in the list, you need to install UltimaSerial. Now your ToolBox should be like this:
5) Place two command buttons along with UltimaSerial and Timer in the UserForm. Now your screen should be like this:
6) Double-click on the CommandButton1, CommandButton2, Ultimaserial, and Timer Objects on the UserForm to create the codes for them. 7) In the Visual Basic code editor, change the default codes (If you decide to type in the codes, you will notice the properties and methods will be displayed in a drop-down menu once you typed in ultimaserial1.) From:
To (Watch for the blue text, we assume button Command1 and 2 for Start and Stop action)
9) Close the Excel Visual Basic Editor, and back to Excel. Make sure you can see the Control ToolBox in your toolbar (the third row in my sample below) If you don't see it, follow View->Toolbars->Control ToolBox to enable it.
10) Add a button from the Control ToolBox to the spreadsheet (Notice the first button on the Control ToolBox toolbar is down. This indicates we are still in Design Mode)
11) Double-click on the button to enter Visual Basic Editor for sheet1. Now change the default code From:
To: (Watch for the blue text)
12) Back to Excel. Exit Design Mode (The Design Mode button is the first one in the Control ToolBox toolbar, when it is down, it is Design Mode; when it is up, it is Run Mode. See Step 10) for more detail )
Last update: 10/05/07 Copyright: 2000-2005 www.UltimaSerial.com
|
|