Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-31-2005, 09:01 AM   #1
Registered: May 2005
Posts: 275

Rep: Reputation: 30
converting vb6 code to python

I have the following server code wrote in vb6:

Option Explicit
Dim sServerMsg As String

Private Sub Form_Load()

'Address must be input as a string
Dim Address As String

'Set the address equal to the web address of the pickle line camera
Address = "http://pl7cam2/operator/image_test.shtml?camNo=1&squarepixel=0&resolution=4CIF&compression=35&color=yes&rotation=0&overlayim age=0&overlaypos=0x0&date=1&clock=1&text=1&textstring=%237%20Pickle%20Exit%20Camera&textcolor=white& textbackgroundcolor=black&textpos=top&duration=NaN&fps=0kkkkkkkkkkkkkkk"

'tells the browser window to display whatever is on the web page of the address
WebBrowser1.Navigate Address

'The port number is arbitrary.
' it's best to use a fairly high number
' because the low numbers are used for
' standard services: 21 for FTP, 23 for telnet,
' 80 for HTTP etc...
Winsock1(0).LocalPort = 10119

'start listening for a connection


'Define the message and show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub

Private Sub Winsock1_ConnectionRequest(Index As Integer, ByVal requestID As Long)

'the winsock control has to be in a closed state
' before it can do anything else. (like accept a connection)

'Let the winsock close

'accept the connection request
Winsock1(Index).Accept requestID

'Define the message and display it in the list box
sServerMsg = "Serving client!"
List1.AddItem (sServerMsg)
End Sub

Private Sub Winsock1_Close(Index As Integer)

'When the other end has closed the connection,
' close server end too

'to continue listening for another connection

'show the connection in the list box
sServerMsg = "Listening to port: "
List1.AddItem (sServerMsg)
End Sub
Private Sub Winsock1_DataArrival(Index As Integer, ByVal bytesTotal As Long)

Dim strTemp As String
'Dim strTemp2 As String
Dim a As Integer
'This event fires when the process on the other end of the connection(i.e the client)
'sends data

'retreive data from socket
Winsock1(Index).GetData strTemp
'Winsock1(Index).GetData strTemp2

'The following code separates each part of the string based on the comma
'that is present in the incoming string and parses it out into its
'respective textbox

a = InStr(strTemp, ",")
txtcoilid.Text = Left(strTemp, a - 1)

'after the first parse you must refine the string as everthing after the comma and
'repeat the process throughout the entire string
strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtwidth.Text = Left(strTemp, a - 1)

strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtlinespeed.Text = Left(strTemp, a - 1)

strTemp = Mid(strTemp, a + 1)
a = InStr(strTemp, ",")
txtexitcoillength.Text = Left(strTemp, a - 1)

End Sub

It has been suggested to me that python is the best anguage to write this program in being that it needs to be on a linux machine. Can anyone offer suggestions or information on translating this code to python or steps to rewrite in python. I have never used linux or python before and am open to any suggestions.
Old 06-02-2005, 02:17 PM   #2
Registered: Apr 2004
Location: Minneapolis
Distribution: Ubuntu
Posts: 45

Rep: Reputation: 15
A good place to start would be the Python tutorial.

What does this VB code do? If you want someone to write the code for you, you probably have to pay them. I'd suggest Google Answers if this is the route you want to take.
Old 06-02-2005, 02:27 PM   #3
Registered: Jan 2005
Location: Washington, D.C.
Distribution: Arch (Custom), CentOS
Posts: 239

Rep: Reputation: 30
First and foremost, welcome to Linux and Python! Python is a great language, and very easy to learn if you've programmed before (in my opinion).

Since you are open to suggestions, I have a few:

-I don't know of any documents on translating code from VB to Python, so I apologize for not being able to help you there. Fortunately VB is pretty easy to read - I think that fact will help you greatly.

-I'd recommend for learning the basic ins and outs (it is a free book in many formats). If you want to jump into more deep stuff, I would just browse between the different reference manuals found on In particular, if you go to that site and look at the python library reference ( I think chapter 7, section 2 is what you are looking to imitate. That is the chapter on how to do socket stuff.

-I'd also recommend the eric3 IDE for python. It is pretty good. It can be found at

I hope I helped a little bit - good luck!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Converting Windows DLL code to Linux shared library DavidW567 Programming 7 07-27-2010 09:15 AM
python: converting a 3 character octal string into and ASCII char llama_meme Programming 1 07-06-2010 03:00 PM
easy python code JoeUser11 Programming 1 01-21-2005 02:40 AM
How to add new apps to Gnome main menu ? / VB6 code compilation to Linux . linuxlover1 Linux - General 3 11-16-2003 06:35 PM
Converting bash command to C code Linh Programming 3 06-13-2003 11:39 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:00 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration