Page 1 of 2

VB2PB - Visual Basic to PureBasic converter...

Posted: Fri Dec 22, 2006 12:50 am
by DevilDog
Hi All,

Background
A while back I thought about how it would be cool to have a VB to PB converter.

I looked around the forums and couldn't find one. There may very well be one but I didn't find one.

So as a programming exercise I decided to try to write one.

My goal was to be able to convert a simple VB application to PB that used no ActiveX controls nor COM stuff.

This might be a cool way to both introduce VB developers to PB and who knows if in the future PB can handle ActiveX controls -that would really open things up. :wink:


Status
VB2PB converts a VB project that contains 2 forms and 2 modules (should be able to handle more) to a PB program.

The VB form has:
  • Textboxes
    Buttons
    Labels
    Optionbuttons
    Checkboxes
    Pictureboxes
    Lists
    Comboboxes
    Frame
    Timer
    Vertical/horizontal scrollbars
The 3 buttons on the vb form do the following:

Code: Select all

1. button 1 - displays a msgbox
2. button 2 - calls a method in a module which in turn:
    a. calls a function which performs a calculation and returns the result 
    b. displays the returned valued in a msgbox
    c. displays the second form
3. button 3 - displays the second form
They obviously don't do anything useful. The point was to mix up the flow of the programs so as to help test the VB2PB program.

One key thing that VB2PB does do which isn't straight forward code to code conversion, is it can handle extracting the icons, jpg or bmps used in a Picturebox control.

If you are not familiar with that, VB stores the ico, bmp and jpg images used in Pictureboxes (and I'm assuming Image controls although I didn't get to test that) in binary form in a seperate file with an .FRX extension and with the same name as the form they're used in.

Also, VB will store the items in a combo box and list box in the same .FRX file.

This made writing VB2PB a bit harder as there wasn't much info that I could find regarding this. Finally I did find one sample VB program that handled the images but not the combo/lists, but I was able to figure it out for the most part.

Future
I'm not currently working on VB2PB as I've got several other projects, but I think the idea still has merit, I just can't further it along for a while.

So rather than let it sit there I thought I would put it out there and see if I could get some help with it from the community.

I am making the source code available to everyone who is interested in helping develop it further. I've commented the code as much as possible.

If anyone wants to help, just reply to this post.

Download and Execute
You can find the download at the bottom of this post.

Extract the files with the directory structure in place.

In the PB folder you will find the VB project file (.vbp) I used for development. If you have VB 6 you should be able to double-click it to load it. You can then run it to see the VB application.

In the PB\Converted folder you will find the PB program that was created during the conversion as well as the ico, bmp and jpg files that were extracted from the FRX file.

In the Program folder you will find the VB2PB program. To use it simply run it and in the first textbox it needs the path to the .VBP VB project file to convert. In the second textbox it needs the directory where it can store the converted .PB program and any image files.

Bugs
I'm sure there are still bugs as it's a work in progress. Here we can list bugs and fix them.

1. VB2PB currently uses "PureCOLOR_SetGadgetColor" to make a textgadget transparent like VB labels. But it's not working correctly and the text gets messed up.

Features
Here we can list features we need worked on.

Download the VB2PB.Zip file from my website: VB2PB.zip

Posted: Fri Dec 22, 2006 4:50 am
by JCV
nice! I'll help during vacant time. I still have to convert many vb apps I made before. :D

Re: VB2PB - Visual Basic to PureBasic converter...

Posted: Fri Dec 22, 2006 8:32 am
by PB
> I looked around the forums and couldn't find one.
> There may very well be one but I didn't find one.

I wrote an app called "vis2pure" way back in 2001, but the official announcement
was lost when the forums changed to phpBB. Here was the latest thread from
when I stopped working on it, although I have been tinkering again lately:

http://www.purebasic.fr/english/viewtopic.php?t=8319

Posted: Sat Jan 20, 2007 5:04 pm
by SFSxOI
@PB;
Yes, I know its an older thread and I hate to bring it up again...but a simple question please...PB, do you have any plans to re-release this as an updated version?

@DevilDog

I found the following caused errors:

Code: Select all

; misc procs
Declare.l Hex2Dec(h$)

and...

Procedure.l Hex2Dec(h$); I'm sure one of these 2 hex2rgb can be removed.
  ; I changed one slightly and somewhere and never got back to clearing this up
  ; h$ can be 0-FFFFFFF.
  h$=UCase(h$)
  For r=1 To Len(h$)
    d<<4 : a$=Mid(h$,r,1)
    If Asc(a$)>60
      d+Asc(a$)-55
    Else
      d+Asc(a$)-48
    EndIf
  Next
  ProcedureReturn d
EndProcedure
I commented them out and it seemed to work OK. Thanks for this :)

Posted: Sat Jan 20, 2007 5:39 pm
by DevilDog
SFSxOI,
It may be that the logic path where that code is encountered had not been triggered with the test vb project that I was using. If it works ok for your needs then great!

I'm glad you can use it. Like I said if anyone can use any part of it or help develop it further that would be fine.

Posted: Sun Jan 21, 2007 2:52 am
by PB
> PB, do you have any plans to re-release this as an updated version?

Not right at the moment... I literally have no time these days, and it's hard to
get motivated anyway when things like PureFORM are so damn good. :)

One thing that kinda stops me wanting to do it, is that there's no easy way to
do PanelGadgets with the Visual Basic editor. You can add one easily, but you
can't switch tabs and drop gadgets onto those tabs. So it's likely that vis2pure
wouldn't support PanelGadgets, which would make it a bit useless, yes?

Posted: Sun Jan 21, 2007 2:57 am
by SFSxOI
"which would make it a bit useless, yes?"

I guess your right, it would in a way make it a bit useless. Thank You :)
PB wrote:> PB, do you have any plans to re-release this as an updated version?

Not right at the moment... I literally have no time these days, and it's hard to
get motivated anyway when things like PureFORM are so damn good. :)

One thing that kinda stops me wanting to do it, is that there's no easy way to
do PanelGadgets with the Visual Basic editor. You can add one easily, but you
can't switch tabs and drop gadgets onto those tabs. So it's likely that vis2pure
wouldn't support PanelGadgets, which would make it a bit useless, yes?

Posted: Fri Aug 14, 2009 3:44 pm
by A M S
Please reUpload this useful application
my problem is here :
http://www.purebasic.fr/english/viewtopic.php?t=38535

Posted: Fri Aug 14, 2009 9:51 pm
by PB
vis2pure wasn't a code converter, it was a form converter. It won't help you.

Posted: Sat Aug 15, 2009 10:45 am
by SFSxOI
I've still got a copy of the VB2PB.zip laying around. Since it belongs to PB, if he gives his permission i'll put it up on rapid share for you to get or somewhere else.

Posted: Sun Aug 16, 2009 9:30 am
by PB
vb2pb isn't mine. Mine is called vis2pure.

Posted: Mon Aug 17, 2009 11:34 pm
by DevilDog
SFSxOI,
I wrote VB2PB, if you've still got the copy of it handy and you haven't already sent it to AMS, I have no problem with you sending it to him.

DevilDog

Posted: Tue Aug 18, 2009 12:07 am
by SFSxOI
@PB I got yours confused, sorry 'bout that...too many V's and B's and v to this and that around here. :)

@DevilDog - I haven't sent it, don't have anyplace to send it, heck its not that large and I could do it as an email attachment, or I could upload it somewhere so he can download. Thanks for granting permission.

@AMS, if you show back up, just PM me and let me know and we will work something out to get it to you.

New download link

Posted: Tue Aug 18, 2009 10:54 pm
by DevilDog
Hey everyone,
I've changed the link in the first post to point to my website instead of PureStorage since PureStorage is down.

You should be able to download VB2PB now. Here's the link again:



http://www.mooresdevildogs.com/VB2PB.zip

Posted: Mon Aug 24, 2009 8:58 pm
by Kwai chang caine
Thanks DevilDog for this good idea 8)

But i have don't understand, how to use the only one file "VB2PB.zp" who is in your ZIP :oops: