1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Switching between screens

Discussion in 'Questions (Windows Mobile)' started by mozaharul, Jan 30, 2009.

  1. mozaharul

    mozaharul Active Member Licensed User

    Hi,
    In the attached program I used two menu items to switch between screens generated at run-time. At the start the left menu option is “Close” and right option is “Next >”. Clicking the “Next >” option changes the “Close” menu option to “< Back” and at the last screen the “Next >” menu option becomes “Save” option, the left option is still “< Back”. Clicking the “< Back” option any time will take to the previous screen. The “< Back” menu option again becomes “Close” when switch back to the first screen.

    The program runs fine in the desktop even in the device without using the soft keyboard. But when keyboard is used in the device then I can not move back and forth using the menu options.
    The place to look for any problem is :
    the “Sub Mclose_click” and “SubMnext_Click” event in the program.
    I set the message and have seen that without using the keyboard on the device highest value generated for variable “m” is 2 (which is OK) but when keyboard is used and try to switch back or forth, value generated for variable “m” is more than 1000 and keeps increasing in each click of “Next >” menu option. Also tried to use hardware library (hardware_SIPchanged event) but could not make it out.

    Regards,
     
  2. klaus

    klaus Expert Licensed User

    You are using the variable m at two places in the hw_SIPChanged routine and in the Mclose_Click , Mnext_Click routines!

    Are you shure that the variable m in SIPChanged is same as the other one you use in the Mclose_Click and Mnext_Click routines.

    You should use another variable name in routine SIPChanged.
    When you use local variables in subroutines, I suggest you to declare these with a Dim keyword at the beginning of the routine like.
    Sub hw_SIPChanged
    Dim mm, h

    Best regards.
     
  3. mozaharul

    mozaharul Active Member Licensed User

    Thanks for the suggestion. Since I declared the variable "m" in the global section, then if I'm not wrong, variable "m" is same used in the mentioned subs.

    best regards,
     
  4. klaus

    klaus Expert Licensed User

    Yes , when you declare a variable in the global routine, it is the same for all routines in the same module.

    Best regards.
     
  5. agraham

    agraham Expert Licensed User

    As Klaus pointed out you seem to be using the global variable m for two different incompatible purposes. In Mnext_Click you seem to be using it as a Form progression counter but in hw_SIPChanged you are using it to hold a calculated height in pixels - this is where the big number comes from. Surely you need to use a local variable in hw_SIPChanged and not upset a global variable used for an entirely different purpose!
     
  6. mozaharul

    mozaharul Active Member Licensed User

    My best regards to both of you, klaus and agraham. I'm ashamed for the silly mistake I made.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice