Windmill Software Ltd |
November 1999 |
Monitor Newsletter Archive |
Issue 16: Magazines and Visual Basic ProgrammingCONTENTSWindmill News - Charting from Excel | Magazines on the Web | VB Corner WINDMILL NEWS: MORE HELP FOR EXCEL USERSThe 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:
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. MAGAZINES ON THE WEBMany 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.
* Oher Magazines you might find Useful
VB CORNER: DISPLAYING YOUR DATA ON WEB PAGESThis 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 FormThe 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 PageYour 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 ControlsNow 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. When the user clicks a button on the form, the event "bubbles" up through the local event handlers, if any (e.g. javascript in the page), and eventually reaches your VB program. Here it generates a document event (click). Since our document is called d, we handle it in d_onClick. 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 CornersIn 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:
Do you have a comment or suggestion for this newsletter? E-mail the editor - Jill - at studholme@zetnet.co.uk 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. SubscribingTo receive Monitor every month please fill in your email address below. We will not pass your address to any third parties. | |
Recommend this Monitor newsletter to a Friend
Home | On-Line Shop | Free Literature and Software Demos | Contents | Search
| Copyright Windmill Software Ltd 2006 PO Box 58, North District Office, Manchester, M8 8QR, UK. E-mail:monitor@windmill.co.uk, Tel:+44 161 833 2782 http://www.windmill.co.uk/ Designed by Studholme.net |