VB conversion help

I am new to Xojo and, because I think the best way to learn a new product is to do something useful with it, I have undertaken a port of a VB program to XOJO. The VB converter is very good but it has left the following block of code untouched. I am assuming because there is no XOJO equivalent ? I would really appreciate someone helping me convert this block to XOJO ?

The block of code is:

Parameters: ByVal rconCommand As String , ByVal gameServerIP As String , ByVal password As String , ByVal gameServerPort As Integer
Return Type: integer
''connecting to server
Dim client As New Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp)
client.Connect(IPAddress.Parse(gameServerIP), gameServerPort)
Dim command As String
command = "rcon " & password & " " & rconCommand
Dim bufferTemp() As Byte = Encoding.ASCII.GetBytes(command)
Dim bufferSend(bufferTemp.Length + 5 - 1) As Byte
'intial 5 characters as per standard
bufferSend(0) = Byte.Parse(“255”)
bufferSend(1) = Byte.Parse(“255”)
bufferSend(2) = Byte.Parse(“255”)
bufferSend(3) = Byte.Parse(“255”)
bufferSend(4) = Byte.Parse(“02”)
Dim j As Integer = 5
For i As Integer = 0 To bufferTemp.Length - 1
bufferSend(j) = bufferTemp(i)
j += 1
Next i
'send rcon command and get response
Dim RemoteIpEndPoint As New IPEndPoint(IPAddress.Any, 0)
client.Send(bufferSend, SocketFlags.None)
'big enough to receive response
Dim bufferRec(64999) As Byte
Return Encoding.ASCII.GetString(bufferRec)

Start by check out UDPSocket

Merek, I have also tried out the VB migration assistant, but it seems to be a real waste of time. It can’t give a working, ready to use compilation even from a simple “helloworld” VB6 app.

I don’t see why you would think it would do that. This is in the initial instructions on the VBMA startup screen:

For tips when migrating from VB, refer to the Migrating from Visual Basic page in the docs.

Thank you all for helping me unravel what the code block I posted does and how I can replicate it in Xojo … most useful …

Paul, I admire your work with the XOJO, but perhaps you have promised a little too much on your website: “Easily migrate your VB project to Xojo using this VB Migration Assistant.”

I have a few bigger VB6 projects, and unluckily Migration Assistant couldn’t migrate anything in my cases. No modules, no classes, nothing…! If you want, I can send you screenshots!

Perhaps the ‘easy’ description needs to be taken off The VB Migration Assistant description. It doesn’t convert any code for you zero. Zip. Nada. But then it’s pretty clear that the utility doesn’t do that and they pretty much say that in the description.

We tell our customers (been doing this 15+ years) that despite both using a BASIC language, there’s no such thing as a converter. Some things in Xojo a so much better than VB that it’s pathetically easy. Other things not so much but still easier. There are just too many differences between VB6 and Xojo for any converter to actually work.

My suggestion, is to simply start over from scratch. Bite the bullet and Learn Xojo. There is no easy button. For what it’s worth we’ve converted (i.e. rewritten) dozens of VB6 apps to Xojo. Each has their idiosyncrasies and assumptions for VB6 that make zero sense in Xojo. Xojo does subclassing and threads incredibly easy while those are near impossible in VB6 (and the VB6 workarounds for those items simply make no sense in Xojo).

I would say relying upon the Migration Assistant or any ‘converter’ tool you can find is only an exercise in frustration. If you expect Xojo to be just like VB6 you’ll end up hating Xojo. Trust me on this as I’ve talked to many developers that try to make Xojo ‘just like’ VB6 and they hate Xojo because of it. They reset their expectations and learn the ‘Xojo way’ and their lives are much better.

So forget about the Migration Assistant or any Converter you find and learn Xojo and start over from scratch.

Yep, I agree with Bob…it’s what I had to do. Learn Xojo from the ground up, and many things are much easier than VB6, so IMO it was worth it.

I’ve seen this happen with some VB projects. Typically they have some unusual or unexpected code in them that causes the resulting XML project to be invalid. If you open the XML project (using something like Firefox), it will tell you the line with the problem. Tweak it with a text editor and the project ought to load.

If you have sample VB projects, that cause this you can submit them in Feedback so we can see if the tool can be updated to accommodate them.

Marketing text aside, the intro screen of the tool is quite clear as to what it does and does not do.

The big benefit of VBMA is that it gets your VB project into Xojo so you don’t have to keep a copy of VB running should you need to refer to old code or layouts.

Using this as a reference while you recreate your project using the benefits of the Xojo language, OO model and framework is always a better idea.

My expanded opinion http://www.bkeeneybriefs.com/2016/01/dont-convert-your-app-to-xojo/ Personally, I wouldn’t even try VBMA but that’s up to you.

Nice article Bob.
I reminds me of my experience when I came to Xojo.

I had a pretty popular Windows app made with VB5 and some DLLs written in Delphi for speed.
I wanted a Mac version and had dabbled with some tools I found.
When I came across Xojo, after a week of playing with it, I found it wasn’t hard to rewrite the INTENT of the VB code.
The things I used Delphi to achieve for speed , actually ran fast enough in straight Xojo.
So I spent 6 months part time, and had a Mac app to release. Fewer features, but a product.

As I added more features to match the Windows app, I found there were better ways to do things.
It wasn’t long before the Mac app was better than the Windows one, so I started building and shipping a Windows app from the same code, end eventually deprecated the original VB one.

Never looked back… as you say … ‘realise Xojo does it better’

I find a good way to convert a VB app is to:

Decide how data is accessed… database or custom files?
Write modules that read write and amend that data.
Probably create a class that wraps that data into an in-memory form.
Duplicate the GUI windows
Look at what each control actually does, and replicate that one by one, window by window.
Move drawing code from windows startup into Canvas paint events.

There are some controls you won’t be able to duplicate without work.
For those, either think of another method to expose the data, or spend some time learning how to subclass more basic controls.
(For example, ‘pictures in lists’ used to be tricky in VB… its trivial in Xojo…)