Question from a noob

Discussion in 'Questions (Windows Mobile)' started by sunnyboyj, Dec 10, 2007.

  1. sunnyboyj

    sunnyboyj Member

    Can someone help me starting with basic4ppc.
    I have used the starting program number-guessing. I want to make a second screen with other questions but I can not start it. It stops after the original program. How do I close the form1 and start up the form2?

    Sub Globals
    'Declare the global variables here.
    Dim number
    End Sub

    Sub App_Start
    number = Rnd (1,3)
    End Sub

    Sub btnGuess_Click
    If Not (IsNumber(txtnumber.Text)) Then
    Msgbox("Een juist nummer invoeren svp")
    End If
    If txtnumber.Text > number Then
    Msgbox("Een kleiner nummer")
    Else If txtnumber.Text < number Then
    Msgbox ("Mijn nummer is groter")
    If Msgbox ("Het juiste nummer!" & crlf & "Opnieuw?","",cmsgboxYesNo) = cYes Then
    number = Rnd(1,3)
    End If
    End If
    txtnumber.SelectionStart = 0
    txtnumber.SelectionLength = StrLength(txtnumber.Text)

    End Sub

    Sub key_Click
    number = Rnd (1,3)
    End Sub
  2. agraham

    agraham Expert Licensed User

    Don't close Form1, as it is your main (first) form it closes your application.
  3. specci48

    specci48 Well-Known Member Licensed User

    Hi sunnyboyj,

    welcome to basic4ppc :)

    The first form shown in basic4ppc is always the "main" form. This form cannot be closed because closing the "main" form exits the program.
    The trick ist to show a second form, and the hide the "main" form from the taskbar so that you cannot switch between both forms. This is done by setting the form.text to space.
    When closing the second form, you should reset the text of the "main" to it's original value.

    I attached a modified sample of "GuessMyNumber", calling a second form with a button click (while hiding the "main" form), and showing the "main" form again after closung form2.


    oops... i should type faster not to miss any posts... ;)

    Attached Files:

  4. sunnyboyj

    sunnyboyj Member

    Thankx for the help!
  5. Rioven

    Rioven Active Member Licensed User

    Off topic, just suggestion

    Hi sunnyboyj
    You may use 'Select-Case' method in your code which is easier to follow during debugging compare to series of 'IF-Then' statements. Combinations of these two methods will do as well.:)


  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