# Visual Basic > Visual Basic FAQs >  Classic VB - How can I get the source code of a compiled VB file (.exe/.dll/..)?

## si_the_geek

For early versions of VB (such as VB3) there are working de-compilers (_if_ you can find them!), however most people who ask are looking for a VB5 or VB6 de-compiler, which is what we will discuss here.


*The short version*
_Basically_ you can't get the source code of compiled VB programs.  Even with the best tools available, you will spend more time 'fixing' and interpreting what they produce than you would re-writing the program.

A re-write is often much quicker than writing the original (as you already know how it was structured etc), and if you have time to spare you could try to write it all in a "better" way too.  The most important thing tho, is to make regular backups of your code files in future - dont lose your work again!


*The long version*
When you write a program, you use a programming language (like VB) which you can read/write as it is _almost_ in English.  

A computer cannot read code written in VB, so a program known as a Compiler converts it into machine code, which is something that you could not read well you probably could if you tried hard, but it would take a very long time and lots of headaches!

There are several major differences between the code you write, and the machine code equivalents.  One of the major differences is variable names - they are only needed for the VB code, not for the machine code.  Another big difference is that a couple of lines of seemingly simple VB code can become hundreds of lines of machine code; Also several different samples of VB code (which do the same thing, but using slightly different coding methods) could produce exactly the same section of machine code.


There are tools available (called de-compilers) which attempt to "undo" the compilation process, and convert the executable file back to VB code.  Unlike de-compilers for some other languages, the ones for VB are patchy to say the least.  The best results that we have heard about on the forums (after _hundreds_ of threads) is getting the form design (eg: textboxes in the right positions), and some function names - very little if any VB code!  (one of the better ones claims it can get "_about 3%_" of the code).

There are two noticeably different ways to compile VB programs, the one that most people use is Native code (your program is converted directly into machine code), and the other is P-Code, which is a "half-way" compilation.  With P-code your program is converted into an intermediate language, and only converted into machine code when the program is running.  This makes the program slower (as it needs to be compiled at run time), and theoretically makes de-compiling easier - but even with programs compiled using P-Code, de-compilers dont do very well.

As VB6 has been available since 1998 (and is being 'replaced' by VB.Net), this is very unlikely to change.

----------

