Exploring the IDE
Launching the eVB tool presents the user with the New Project dialog, which supports the creation of four types of projects, based on the SDKs loaded on my machine:
Windows CE Formlessfor use in environments with no keyboard or display
Windows CE Palm-size PC 1.2
Windows CE HPC Pro
Windows CE for Pocket PC 2002
I selected Windows CE for Pocket PC 2002 in order to get started on the StatCalc app, and a basic project was created for me (see Figure 1).
Figure 1 A blank Pocket PC 2002 project.
Scanning the environment reveals nearly identical functionality to Visual Basic 6.0, including the Object Browser, Project Explorer, Properties Window, Toolbox, and Visual Basic debugger. ActiveX controls can be added to the project using the standard References window, but StatCalc 1.0 won't require any of these. The two primary features differentiating VB and eVB are the ability select a target device from the toolbar, and the variety of Windows CE tools available from the Tools, Remote Tools menu. These tools include Heap Walker, Process Viewer, Registry Editor, File Viewer, Spy, Zoom, a Platform Manager configuration editor, the Windows CE Control Manager, and an Application Install Wizard. For now, I'll bypass this advanced functionality and simply lay out my StatCalc screen, mimicking the StatCalc app I built for the eVC++ article (see Figure 2).
Figure 2 The eVB StatCalc screen.
As with the C++ app, each time the user clicks the Add! button the value will be added to the list box, and the values for mean and standard deviation will be calculated. The code for this button-click event handler is shown below, along with three helper routines: displayMean(), displayStdDeviation(), and calculateMean().
Private Sub btnAddValue_Click() lstValues.AddItem (txtValue.Text) displayMean displayStdDeviation End Sub Private Sub displayMean() Dim m As Variant m = calculateMean lblMeanValue.Caption = CStr(m) End Sub Private Sub displayStdDeviation() Dim Mean As Variant Dim Sum As Variant Dim i As Variant Sum = 0 Mean = calculateMean Do While (i < lstValues.ListCount) Sum = Sum + (CDbl(lstValues.List(i) - Mean) ^ 2) i = i + 1 Loop lblStdDeviationValue.Caption = CStr(Sqr(Sum / lstValues.ListCount)) End Sub Private Function calculateMean() Dim i As Variant Dim Mean As Variant i = 0 Do While (i < lstValues.ListCount) Mean = Mean + CDbl(lstValues.List(i)) i = i + 1 Loop calculateMean = CDbl(Mean / lstValues.ListCount) End Function
As we have seen, development for Windows CE using either Visual C++ or Visual Basic brings a level of ease-of-use and control very similar to that offered by Microsoft's flagship Visual Studio development tool. In the next article, we'll retool the StatCalc example to perform database access using the ADOCE API.