As I mentioned before, VB is a powerful tool and it is perfect if you want to get into programming. It is intuitive and easy to use, plus you can easily find information about any topic in the World Wide Web.
Today I'm gonna show how to manipulate VB6 and create a simple *.exe step by step. Our program will add two numbers and will give you the result. As simple as that.
First, download VB6 from my GitHub account:
https://github.com/rolando-febrero/Tutorial/commit/5d1c52dc103996f91eb16c17a03d4a0e08438af3
Once you double click on it, you'll see:
There are two options:
Reg Key and Run Visual Basic. If it is the first time you are running this program in your PC, you need to click on the first option. This option will add some information in your registry allowing you to create .exe . So click on that option, and then click on Yes.
Now click on "Run Visual Basic 6"
Select "Standard EXE" and click Open. Now we are going to see the Form1.
In VB "form" is like our panel or window. We can make it visible or not. At the right side, we can see a properties windows with many options available for the object we want to modify. As I said before is very intuitive, so just take a look and play with them.
General tool bar in on the left side. There are all the objects we can use for our program (text fields, buttons, labels, pictureBox, etc) Just drag and drop on the form to add them.
In our case, we need 3 textBox (Sum of two numbers and 1 for the result)
You can modify the text that those objects are showing by selecting them and modify the values in properties windows.
Now, let's start coding our button. Basically, we need to sum the first two values and show the result in the last textBox.
Double click on your button. By doing this, we can see the area where we program the object (button), in other words, the instructions it needs to perform any task. Also in this window you can see two drop down menu on top, one to select the object ("Command1" our button) and the other to select the "action" (click).
Copy/Paste this code:
Sum = Val(Text1) + Val(Text2)
Text1 = ""
Text2 = ""
Text3 = Sum
As any other programming language, we need variables. In this case "Sum" is the variable that is going to hold the result.
Now, click on "Start" to see how your program works.
Now let's test it. Type the number and then click on the button to get the result.
At this point, we have a functional program. Simple, but it does what we expected to do. Now, it is time to make it an .exe
Go to File and select the option "Make Project1.exe". Select where you want to save it and that's it. Now you have your first executable (.exe). As simple as that.
Of course, our new program doesn't have validation or fancy stuff. You can play with it and start adding more code and make it look better. You can modify the view, or add a timer, or a message, or even change the icon. The limit is your imagination.