Pages

Sunday, June 8, 2014

Converting VB6 to Android: Die Roller

I mentioned quite a while back that I was going to start converting some of my old VB6 apps to Android.  That post wasn't really helpful, just a slice-of-my-life type thing, but I've noticed that it is the most viewed post I have.  I've done a few other conversion since, but just as tests, not complete apps.  So, I'm going to walk you through conversion of one of my old VB6 apps from start to finish, and explain exactly what I do.  You'll be learning Android programming (along with me) from the standpoint of a VB6 programmer.  I'll try to throw in c# references as well, but that won't be the focus, simply because that's not what the original post was about.


Now, I know a lot of you are looking for converter programs, but I don't use them.  For one, it keeps me from necessarily understanding how the Android apps work.  I learn by doing, so converting the apps by hand makes it more likely that I'll be able to write a new app from scratch.  Plus, I just like reinventing the wheel sometimes, not to mention that a lot of converters I've used for other things create crap code.  I don't like crap code.

To start with, get eclipse or something similar installed, and install the Android SDK.  There are a lot of tutorials out there on how to do it.  I've already got it all installed, and don't have a clean machine to start with, so I can't walk through those steps.  But this page seems to be fairly complete.  For the record, I have Eclipse Juno, according to the splash screen, so version 4.2.

Create a new project and choose Android Application Project.  Set an app name (TMDice for me), a project name (TMDice, the default) and a package name (com.deskchange.tmdice).  Then set your target parameters.   I'm targeting Android 4.1 (Api 16) and the minimum required SDK is API 8: Android 2.2 (Froyo).  I'm using those settings simply because they are what I've used before, and they worked, and I don't feel like changing them.  If I run into code that I need a newer API for, I'll change at that time.  I have "Create a custom launcher icon" checked, and "Create Project in Workspace".  Hit next.

The next screen is the icon customization.  You could skip this and just modify the icon later.  I am using this dice image I found here.  Eventually, I'll replace it with an image of my own.  I'm changing it to a purplish background, just for grins.

The next screen has "Create Activity" checked and "Blank Activity" selected.  The next screen names your activity, and I'm leaving that all at the default.  The next screen is telling my I'm missing required dependencies, which doesn't make sense if I've used this setup for my other tests, but I'll click "Install/Upgrade" anyway.  Maybe I used a lower version last time.  A screen pops up asking me to accept something, and I selected "Accept All".  When that's done, I'm back at the dependencies screen and click the finish button.

We now have the blank app created.  Next time, we'll try to actually do something with it, probably starting with setting up the UI.

No comments:

Post a Comment