Issue 16: Magazines and Visual Basic Programming
WINDMILL NEWS: MORE HELP FOR EXCEL USERS
The Help for our Harvester program has been improved for Excel users. It tells you, for example, how to chart data in real-time from cells in the spreadsheet. As the values change in Excel they change on the chart. You can similarly log data from Excel cells: time-stamping every reading. You can download the new Help from the Windmill Help page.
Harvester can route data from many different sources, not just Excel, into a Windmill data acquisition and control system. It obtains data from Windows applications using dynamic data exchange. The data then becomes accessible to other Windmill modules, like Chart and Logger.
Many Windows applications make data available over DDE. For instance:
- industrial networks such as LonWorks and FIP
- data acquisition hardware drivers
- data entry software
- analysis programs
- your own code
- other spreadsheets
Without the Harvester program, Windmill can only respond to requests from a DDE client. With Harvester, Windmill can take the initiative and start and stop DDE conversations.
Harvester costs 175 pounds (around 281 US dollars or 278 Euros). More details are on the Harvester page.
Many magazines publish on the internet and offer comprehensive archives of previous issues. Here we cover some of the more useful in the data acquisition field.
- Industrial Technology
Updated weekly for product design engineers and machine builders. UK-based but includes an enormous library of articles under category headings like Sensors; Test and Measurement; and Drives, Motors and Controls. You can browse categories or search through the entire archive. Also covers European exhibitions and conferences.
- The Automotive Test Report
Although primarily for automotive engineers, this newsletter
contains many articles that are also useful in more general data
acquisition applications. The archive goes back to January 1999,
with titles such as "Data-Acquisition Systems Help Ensure
Quality Products", "What's Up With Smart Sensors?" and "Test
More Modules in Less Test Time".
- Control Engineering International
Covers control, instrumentation and automation systems. The on-line version appears to include every thing you'd find in the copy on your desk, plus some articles unique to the web presence.
American based but with global coverage, it offers industry news, details of new products, articles, tutorials and discussion forums. The site also lets you search 3 years of back issues.
The discussion forums let people paste questions and hopefully receive answers. However, there are many more questions than answers. Three boards are available - one to help buyers find products and suppliers; one to post automation or control problems; and one to discuss ARC Net. They are reasonably busy for bulletin boards, with postings every couple of days.
- Test and Measurement World Online
This magazine is aimed at engineers who test electronic products and components. It offers articles archived back to 1997 on topics like Stand-Alone Test Instruments, PC-Based Test and Environmental Test. You can also search for products, but rather inconveniently have to do so by issue date.
- Electronics Times
The dot electronics site encompasses Electronics Times and other related magazines. It is news orientated and updated daily, with weekly compilations archived. A good place to look for European industry, technology and business news, but not the site to find articles or tutorials.
- Pollution Enginering Online
Covers news, features and products for measurement, monitoring, pollution prevention and air and water treatment around the world. A monthly column discusses information technology issues and how they apply to the environmental industries. A series of case studies show how environmental problems are successfully solved.
- Flow Control
The US-based Flow Control Magazine is a very good resource for the fluid handling industry - focusing on control, containment, and measurement. It features articles, news reports, case studies and US product directories. It also invites readers to participate in a discussion forum.
Oher Magazines you might find Useful
- Electronic Business Asia
- Provides comprehensive coverage of the electronics industry
- Global Design News
International web site for product designers.
- Scientific Computing and Instrumentation
News, products and feature articles.
Science articles and product news.
- Engineers Australia
Australian and world engineering news and articles.
- Instrumentation and Automation News
US product information.
- Instrumentation & Control Systems
Control technology for US-based engineers and engineering management.
This month we discuss how to use an HTML page to generate the user interface for your Visual Basic application.
You can download the code for this month's VB corner.
- Preparing your form
- Loading the HTML page
- Sending data to your Form controls
Preparing Your Form
The html container control in your VB form will display a normal HTML page. The page we have prepared as a sample is called start.htm. The page itself can be viewed with Internet Explorer. You can edit the html in any editor, for example Notepad. Start.htm uses normal html tags, but where controls or text fields will interact with the VB program itself, we need to identify them. We do this by giving them an ID, for example ID=laStatus. We can change the text in the laStatus element from within our VB program.
Loading the HTML Page
Your VB program needs the Microsoft Internet Controls to use the HTML container. In your VB project, click on Project.Components, and make sure Microsoft Internet Controls is checked.
You add the web browser control to your VB form - we have called ours: wb
In your Form_Load routine you now need to load a document into your web browser control. The VB code is:
Start_FileSpec = "c:\start.htm" wb.Navigate Start_FileSpec
Because the page takes time to load, we cannot try to interact with it until it has finished loading. The Web Browser control generates an event when it finishes loading the page. So in the form_load routine we wait until a flag indicates the page is ready:
' wait for the page to finish loading ... HtmlStarted = False While Not HtmlStarted DoEvents Wend
The flag HtmlStarted is set true in an event handler in wb_DocumentComplete, where we also set a variable to represent the document itself:
Set d = wb.Document HtmlStarted = True
Linking to your Form Controls
Now that the page is up and running we can receive events from the controls on the form, and also send new text for display on the form.
All the click events come through here, so we must determine which control has been clicked, and then do the appropriate thing. In our example we just set flags to say the event has occurred. Here is the whole routine:
Private Function d_onclick() As Boolean ' Pick up the operator clicking on the form buttons On Error GoTo d_onclick_Error ' Handles all button clicks from all screens a$ = d.activeElement.Id Select Case UCase$(a$) Case "PB_CONFIRM" ' Set the action confirmed flag flOpAcknowledged% = True Case "PB_CLOSE" ' shutdown at the end of the next test loop flAppFinished% = True End Select d_onclick_Exit: Exit Function d_onclick_Error: Resume d_onclick_Exit End Function
When we want to display something on the page, we find the control through its ID, and set new text. The following routine changes the text in the status element:
Private Sub ShowStatus(myText$) Set objForm = d.All("laStatus") objForm.innerText = myText$ End Sub
If you want to change the way the text is displayed, you can incorporate HTML tags and use:
objForm.innerhtml = myText$
Future VB Corners
In December's VB corner we will put data acquisition and control into our page by extending our HTML container to include the Windmill IML Tools ActiveX control.
Our other Visual Basic articles are in:
- Monitor # 13, Using DDE to get data from your instrument into your VB Program
- Monitor # 14, VB Programming Tools
- Monitor # 15, Controlling Windmill programs from Visual Basic code
- Monitor # 18, Displaying data from Windmill in an HTML page
- Monitor # 21, Other Visual Basic resources
Do you have a comment or suggestion for this newsletter? E-mail the editor - Jill - at [email protected]
Copyright 1999 Windmill Software Ltd. All rights reserved. This newsletter may be distributed in its entirety. However, individual sections may not be reproduced without the prior written agreement of Windmill Software Ltd.
To receive Monitor every month please fill in your email address below. We will not pass your address to any third parties.