Android Question Convert VB6 to B4x

CONVERT VB6 to B4x
This is Proof of Concept Demonstration
Zip File 1: [01-Guess_V4X_Original.zip] this is a B4J program that “asks” the user for a (n integer) number. The user must click on the Guess button or press the Enter key. If the user has entered the correct number the program responds “Well Done!!!” If the user enters a number which is lower than the number wanted the user receives the message “my number is higher”. And if the number entered is too high the message “my number is lower”.
There is an error in this program if a number is entered and the “Guess” button is clicked the error appears:
Unexpected event (missing RaiseSynchronousEvents): txtnumber_focuschanged
I have no idea on how to fix this error. However the program keeps running as expected until the user chooses the correct number.
Zip File 2: [02- Guess_VB6_Source.zip] this is the VB6 program that that “asks” the user for a (n integer) number. The user must click on the Guess button or press the Enter key. If the user has entered the correct number the program responds “(nn) Well Done!!!” The “nn” is the number the use entered. If the user enters a number which is lower than the number wanted the user receives the message “my number is higher than nn”. Where “nn” is the number the user entered. And if the number entered is too high the message “my number is lower than nn”. The “nn” is the number the user entered.
Zip File3: [03-Guess_VB6_Executable.zip] for some reason I cannot download this file. This is just the executable file of the source code in Zip File 2. If you need this perhaps we can work something out.l
Zip File 4: [04-Guess_XXX_Form.zip|this contains the .frm file for the VB6 Guess program and the and the corresponding .json file. The JSON file is added to the project. So now I convert the .frm file to the .json file.
a. Make a new B4J Project (Guess)
b. Run BalConverter with the .frm file (by mmieher
Zip File 5: [05-Guess_XXX_Translation.zip] here are the original VB6 source code (frmGuess.txt) , a temporary file showing how the translation took place (TEST001V4XFRMGUESS_NOTE.txt), and a third file (VBfrmGuess.vb) showing the generated (translated?) source code.
c. Delete all the source code from the project
d. Copy the generated source code into the project
Zip File 6: [06-Guess_V4J_Converted.zip] and this file is the zipped up B4J file that will run. There is one small adjustment than can be changed in the generated code. The conversion routine “assumes” that all controls that can have tooltips have a tool tip. If no tooltip is found the tooltip gets generated as ?? unk [TOOLTIPTEXT]??. This looks bad upon program execution so I changed it to blanks. Also the same problem exists with captions. So I changed those captions to blanks.
And when you run the program it mimics the VB6 program.
So, for what it is worth. I started writing programs (for money) in 1966. I started my own company in 1976. I wrote a School Administration System (Headmaster). The system was originally written in Applesoft Basic, when the PCs came out I wrote a routine to “port” the Applesoft Basic to GW Basic. Microsoft came out with a compiler called QuickBasic (not to be confused with Quick Basic an interpreted Basic dialect). We had “full screen” processing in the system before anyone knew what “Windows” was. When Microsoft release VB3 I wrote a routine to convert the QuickBasic to VB3, and later the VB3 was converted to VB6 which was a reasonably easy task. Then Micosoft decided to kill Visual Basic. I had 300 school districts running my software. And as you know there was no upgrade path to VB.Net (which was really verbose C). So I wrote 3 routines that converted the VB6 code to PHP, HTML, JavaScript, and CSS. This was no small task. I eventually sold the company. So I was looking at this dialect of Basic and wondered if “any” VB6 program could be converted to this dialect of Basic. So I modified “some” of my conversion code to support this dialect of Basic. And as you can see it works (unmolested by humans). So I am wondering if anyone wants to continue converting VB6 to B4x. I have an almost complete BNF of VB6 the code to read tokenize and parse the VB6 statements. Most of the translation of the pasrsed statements is done via tables, so there is not much coding to be changed, but a whole lot of changes to tables. If you are interested let me know.

By the way I get that "RaiseSynchronousEvents" error on the translated program also.

Happy Computing
Charlie
 

Attachments

  • 01-Guess_V4X_Original.zip
    9.9 KB · Views: 44
  • 02- Guess_VB6_Source.zip
    27 KB · Views: 54
  • 04-Guess_XXX_Form.zip
    2.7 KB · Views: 38
  • 05-Guess_XXX_Translation.zip
    8.8 KB · Views: 37
  • 06-Guess_V4J_Converted.zip
    5.6 KB · Views: 44

ernschd

Active Member
Licensed User
Longtime User
Hi, I can't contribute to the actual topic, but here would be my solution to fix the "RaiseSynchronousEvents" in the B4J program:
B4X:
Private Sub btnGuess_Click
    Try
        Dim intTheGuess As Int
        If Not(IsNumber(txtNumber.Text)) Then
            lblMsg.Text="Please enter a number between 1 and 100"
            Return
        End If

        intTheGuess = txtNumber.Text
        If intTheGuess > intChosen Then
            lblMsg.Text="my number is lower"
        Else If intTheGuess < intChosen Then
            lblMsg.Text = "my number is higher"
        Else
            lblMsg.Text = "Well Done!!!"
        End If

        txtNumber.SelectAll
        txtNumber.RequestFocus           
    Catch
        Log(LastException)
    End Try
End Sub

Private Sub gvh_KeyPressed (KeyCode As String) As Boolean
    'Log ("key pressed: " & KeyCode)
    If KeyCode = "Enter" Then btnGuess_Click
    Return True
End Sub
 
Upvote 0
Hi, I can't contribute to the actual topic, but here would be my solution to fix the "RaiseSynchronousEvents" in the B4J program:
B4X:
Private Sub btnGuess_Click
    Try
        Dim intTheGuess As Int
        If Not(IsNumber(txtNumber.Text)) Then
            lblMsg.Text="Please enter a number between 1 and 100"
            Return
        End If

        intTheGuess = txtNumber.Text
        If intTheGuess > intChosen Then
            lblMsg.Text="my number is lower"
        Else If intTheGuess < intChosen Then
            lblMsg.Text = "my number is higher"
        Else
            lblMsg.Text = "Well Done!!!"
        End If

        txtNumber.SelectAll
        txtNumber.RequestFocus          
    Catch
        Log(LastException)
    End Try
End Sub

Private Sub gvh_KeyPressed (KeyCode As String) As Boolean
    'Log ("key pressed: " & KeyCode)
    If KeyCode = "Enter" Then btnGuess_Click
    Return True
End Sub
Thank you for your quick response but the "fix" doesn't work I still get the error and the "Catch" doesn't get executed. It appears the error is happening in "Private Sub cmdGuess_FocusChanged (HasFocus As Boolean)" error: "Unexpected event (missing RaiseSynchronousEvents): cmdguess_focuschanged" so I am going to put the try catch there
 
Upvote 0
Thank you for your quick response but the "fix" doesn't work I still get the error and the "Catch" doesn't get executed. It appears the error is happening in "Private Sub cmdGuess_FocusChanged (HasFocus As Boolean)" error: "Unexpected event (missing RaiseSynchronousEvents): cmdguess_focuschanged" so I am going to put the try catch there
Well that was a mistake just put me into an endless loop. Gonna ignore the error now!
 
Upvote 0
Top