Simple Converter using If Else statement in Visual Basic

Another Visual Basic tutorial for beginners out there. Today, I want to share you my Simple Converter Program using If Else statement, the source is very easy for you to understand. No worries about the sure code, just simply secure the objects you are be needing in order to run the program.

In this project you are going to create the following objects:
  1. FRAME and change its caption to "Converter".
  2. COMBO BOX and name it "cboselectconvertion", in the Text property just type ”Select Conversation”. In the List just key-in Pound to Kilo, Kilo to Pound, Centimetre to Foot, and Foot to Centimetre
  3. TEXT BOX and name it “txtvalue1”, in the Text property just input “0”.
  4. Another TEXT BOX and name it “txtresult”, in the Text property just input “0”.
  5. COMMAND BUTTON and name it “cmdconvert”, in its caption simply type “Convert”.

In your COMMAND BUTTON, double click and insert the following codes:

If cboselectconvertion = "" Then
txtvalue1 = "0"
txtresult = "0"
ElseIf cboselectconvertion = "Pound to Kilo" Then
txtresult = txtvalue1 / 2.2
ElseIf cboselectconvertion = "Kilo to Pound" Then
txtresult = txtvalue1 * 2.2
ElseIf cboselectconvertion = "Centimetre to Foot" Then
txtresult = txtvalue1 / 30.48
ElseIf cboselectconvertion = "Foot to Centimetre" Then
txtresult = txtvalue1 * 30.48
End If

Once you almost done, your output may look like this:


And you had properly inserted the codes, after the selection of your desire conversion option, you program look like this:


If you encounter some errors you can debug and refer the source and objects I’ll give because I have been tested the program already and working find. You can also raise your questions here using the comment box system. 
Related Posts Plugin for WordPress, Blogger...

1 comment:

Thanks for Commenting us, your comments are highly appreciated!