Help/tips to make this app run faster

Discussion in 'Questions (Windows Mobile)' started by J12345T, Jul 9, 2007.

  1. J12345T

    J12345T Member Licensed User

    Hi all,

    I've re-posted this from the end of another thread.

    The application is a fuel calculator for the Airbus A330. Prior to push back there is a sometimes complicated procedure to work through with respect to weights and fuel. I thought I might be able to write an application to aid in the procedure. This is my first attempt at any real programming so my code may be a bit messy and hard to follow.

    Basically I've created a soft number pad to be used with fingers. The data goes into a table called table1 and is initialised by a table called table1init.

    The input field starts on the right hand side of the table and with every push of the ENT button cycles to the next appropriate field. When it comes time to amend the fuel load press the F button to cycle through the various options.

    Press the Wt button to access the next page (called CatB) then press the same button again to get back to the Wt page.

    I know it won't mean much to most as it is very task specific but I'd appreciate any input.

    One last thing. On the desktop the input cell is 'highlighted' so you can see which cell you're working in but on the device this doesn't happen for some reason. Any ideas?

    Thanks

    JT.
     

    Attached Files:

  2. agraham

    agraham Expert Licensed User

    I wish I had an A330 to play with! A neat little application.

    Suggestions

    You should load the table automatically on starting the app. This would avoid the exceptions caused by pressing a numeric key before the table is loaded.

    You have a neat way of identifying a numeric button but the code is unnecessarily repeated for each button. You could abstract this to a sub as follows. Also I am surpised that B4PPC lets you get away with the syntax "table1.cell(c,r)sender.text", grammatically there should be a string concatenation operator "&" in there.

    Sub ButtonX_click
    update_cell(sender.text)
    End Sub

    sub update_cell(key)
    if Sound_flag = 1 then sound("Tick.wav")
    c=table1.selectedCol
    r=table1.SelectedRow
    table1.cell(c,r)=table1.cell(c,r)&sender.text
    end sub

    There also seem to be other bits of oft repeated code such as

    table1.cell(table1.ColName(d),4)=table1.cell(table1.ColName(d),2)-table1.cell(table1.ColName(d),3)

    that could be abstracted into a sub. For readability and maintainability of code it is always as well to put a repeated function into an appropriately named sub and pass any needed parameters to it.

    You've left a messagebox on the right arrow key!
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    The code attached replaces all Button0-9_Click with ButtonX_Click sub using AddEvent keyword (agraham idea).
    Add Table1.Focus if you want to see the highlighted cell (it is also in the code).
    The application ran pretty smoothly on the device, is there a specific method that takes too long?
     

    Attached Files:

  4. J12345T

    J12345T Member Licensed User

    Thanks Erel and Agrahm,

    I'll have a look at it later today. Re the application speed it probably has more to do with my ancient Toshiba e310 device; but any improvements are v. much appreciated:)

    Thanks again,

    JT
     
Loading...