|
|
|
Figure 2: Access to a variety of new controls on the General tab. |
MobileVB Controls When you create a Palm OS project, MobileVB creates a blank form with the correct size for a Palm OS device. You may be tempted to begin developing a project by dragging and dropping the intrinsic VB controls, as you would normally do with a traditional Visual Basic project. But if you look further, you will see an entirely new set of controls in the General tab of your toolbox (See Figure 2). It is with these newly available controls (AppForge calls them Ingots) that you will devise your interface and construct your project.
Often, these controls provide a greater set of functions than their VB counterparts, making them much more powerful than the intrinsic controls. Table 1 details the MobileVB controls:
Table 1: Sorting out the MobileVB Ingots (controls).
MobileVB Control Name
|
What it does…
|
AFTextBox
|
Like its VB counterpart
|
AFComboBox
|
Reads textual input and/or prompts the user to select an item from a menu
|
AFListBox
|
Displays a list of varying size and content; the user can select one or more of the items in the list box to provide input
|
AFGrid
|
Displays text in a spreadsheet-like control from which the user can select one or more grid elements to provide input
|
AFLabel
|
Used like the standard VB label control
|
AFGraphicButton
|
Provides standard button options but can display a picture instead of a shape
|
AFButton
|
Similar to the VB CommandButton control
|
AFCheckBox
|
Provides a True/False option
|
AFRadioButton
|
Provides the option of selecting exactly one item from a list of items
|
AFGraphic
|
Displays graphics on the screen; uses the MobileVB Graphic Converter to create a proprietary .rgx or .jpg image
|
AFShape
|
Draws rectangles, squares, circles, and ovals
|
AFFilmstrip
|
Animates a series of graphics on the screen
|
AFMovie
|
Displays a movie on the screen after it has been converted from AVI to RMV
|
AFHScrollBar
|
Places a horizontal scrollbar on the form
|
AFVScrollBar
|
Places a vertical scrollbar on the form
|
AFSlider
|
Allows user input or output based on magnitude.
|
AFTone
|
Plays simple musical tones
|
AFScanner
|
Provides barcodes scanning in a variety of formats
|
AFSerial
|
Sends and receives data through a serial port
|
AFInetHTTP
|
Connects to the Internet
|
AFSignatureCapture
|
Reads signatures, stored as String data, for user input
|
AFClientSocket
|
Provides a variety of functions for performing socket-based communication
|
Sprite Field
|
Controls sprites and receives events during game progress
|
Sprite Control
|
A non-visual Ingot that eases sprites
|
AFTimer
|
Like the standard Timer, used to execute code at intervals
|
The VB IDE can become cluttered with the new controls, so if you prefer, you can create a new tab to which you can copy the MobileVB Ingots. To create the MobileVB tab, right-click on the General tab, select Add Tab and then name the new tab. Notice the small yellow letter “i” that allows you to distinguish between standard controls and MobileVB controls. You can now move the MobileVB controls by dragging and dropping them to the new tab.
The remaining IDE, including the Form Layout window, Property window, Project Explorer, and menus, continues to function as you would expect, although MobileVB adds an additional AppForge-specific menu with the following functions (Table 2).
Table 2: AppForge adds another menu with specific functionality to the Visual Basic IDE.
AppForge-specific Menu Item
|
What it does…
|
Database Converter
|
Converts Microsoft Access database tables to the Palm Database (.pdb) format and generates a VB code module for the database, providing an interface for accessing and modifying the Palm Database
|
PDB Database Viewer
|
Displays the internal schema and data records in the Palm Database file. Also displays other useful information, including the internal database name, CreatorID, and TypeID of the database, and the number of records in the database
|
Font Converter
|
Converts TrueType fonts (ttf) into AppForge fonts (cmf)
|
Font Viewer
|
Displays the properties and characters for AppForge fonts
|
Graphic Converter
|
Converts bitmap files (bmp) into AppForge graphic files (rgx).
|
Graphic Viewer
|
Allows you to view AppForge graphic files (rgx)
|
Movie Converter
|
Converts AVI movies to AppForge movie files (RMV)
|
Movie Viewer
|
Allows you to view RMV movies
|
Universal Conduit Configuration
|
Configures a conduit for your application
|
Compile and Validate
|
Compiles and checks code for error
|
Deploy to Device
|
Uploads a compiled project to a handheld device
|
AppForge Settings
|
Applies the settings for an AppForge project
|
Open Project
|
Opens AppForge projects
|
Zoom Level
|
Opens a Zoom window, allowing you to view forms in a larger format
|
Creating a New Database Application with MobileVB
|
Writing Some Code The module you added to the project contains all the necessary code for directly accessing the Palm Database, leaving you responsible for adding the appropriate code in the VB events. When the button Ingots are clicked, an event is raised. Using these events, it’s easy to add records, navigate the existing records, or delete records. Begin with the creation of a new record, which occurs when btnNew is clicked.
Along with the Palm OS, MobileVB provides templates for the Pocket PC, Symbian P800, and the Nokia Communicator.
|
|
Begin by opening the Code window to create a variable called NewRecord. The variable should be of type Boolean; that is, it holds a yes/no, true/false, or 1/0 value. Inside the btnNew_Click event, begin by setting the NewRecord variable to True. Next, set txtItem and txtQuantity to “”. You’ll be setting the TextBoxes to “” on several occasions and with that in mind, create a new procedure called ClearDisplay to set them. Then call the procedures as needed. The following procedures are finished:
Private NewRecord As Boolean Private Sub btnNew_Click() NewRecord = True ClearDisplay End Sub Private Sub ClearDisplay() txtQuantity.Text = "" txtItem.Text = "" End Sub
Next, handle the forward and back () buttons. The code is nearly identical for both items and looks like this:
Private Sub btnBack_Click() PDBMovePrev dbInv DisplayInfo End Sub Private Sub btnNext_Click() PDBMoveNext dbInv DisplayInfo End Sub
The next item is the btnDelete code. Again, it uses the ClearDisplay sub procedure and the NewRecord variable. It checks to see if there is a record, and if so, deletes it. Here is the code:
Private Sub btnDelete_Click() If NewRecord Then ClearDisplay NewRecord = False DisplayInfo ElseIf PDBNumRecords(dbInv) > 0 Then PDBDeleteRecord dbInv DisplayInfo Else MsgBox "No records to delete" End If End Sub
Before moving on, let’s look at the Form_Load event. This event checks to see if the database exists and if not, creates a new one. You’ll also move to the first record in the database. The code you need is in Listing 1.
At the end, the Form_Load event calls the DisplayInfo sub procedure. This procedure (in Listing 1) contains the code that actually displays the information on the screen. You only have two buttons left to deal with. The first is btnSave, which saves the database record you currently have displayed, and btnExit, which causes the program to end. The following procedures finish the application:
Private Sub btnSave_Click() Dim MyRecord As tInvRecord If NewRecord Then PDBCreateRecordBySchema dbInv End If MyRecord.Item = txtItem.Text MyRecord.Quantity = txtQuantity.Text PDBEditRecord dbInv WriteInvRecord MyRecord PDBUpdateRecord dbInv DisplayInfo End Sub Private Sub btnExit_Click() Unload Me End Sub
MobileVB does a splendid job of integrating Palm development into the VB IDE, and is undoubtedly one of the easiest to use all-around development tools available for the Palm. The tools are especially easy to use for developers that are already experienced with VB, as the learning curve is nearly nonexistent. If you are a VB developer and want to write software for mobile devices like the Palm OS, look no further.
| |