Visual Basic Programming

Page 30

We have currently covered all the basics of programming, but still have lots left to learn. All of the stuff you learn from here is your own perseverance to learn more. We will however shortly create a database, which is definitely in the more advanced realm of programming. On this page, you are given the opportunity to make a conversion program. If you really have no interest, I suggest you download the zip files. However, this program does show the importance of writing comments in your own coding. But hey, at least YOU do not have to search for all the conversion factors for this program. I have already found the ones I want to use. By the way, I could never keep my sanity to give directions to make a program like this. This is also your opportunity to do something on your own if you wish to. I am stopping after the tables. I have given you a link to the completed program which is zipped at the bottom of this page. So if you want to try this program, see the tables below:

Conversion Factors for Area

To convert from To Multiply by Conversely, divide by
Acres Square Centimeters 40,469,000 40,469,000
Acres Square Feet 43,560 43,560
Acres Square Meters 4,047 4,047
Acres Square Miles 640 (Divide) 640 (Multiply)
Square Miles Square Meters 2,591,314.38 2,591,314.38
Square Miles Square Feet 27,878,400 27,878,400
Square Miles Square Centimeters 25,899,881,103 25,899,881,103
Square Meters Square Feet 10.76 10.76
Square Meters Square Centimeters 10,000 10,000
Square Feet Square Centimeters 929 929

Be sure to notice that Acres to Square Miles divides and multiplies conversely (obviously). I use divide because it is obnoxious to show such bizarre decimals. For instance, there are approximately .00002296 acres in one square foot. It looks much better in coding just to divide the amount of square feet by the amount of square feet given by the amount of square feet in an acre (43,560).

Conversion Factors for Distance

To convert from To Perform operation Conversely, perform operation
Feet Furlongs 660 (Divide) 660 (Multiply)
Feet Inches 12 (Multiply) 12 (Divide)
Feet Meters .3048 (Multiply) 3.28 (Multiply)
Feet Miles 5280 (Divide) 5280 (Multiply)
Feet Rods 8 (Divide) 8 (Multiply)
Feet Yards 3 (Divide) 3 (Multiply)
Inches Yards 36 (Divide) 36 (Multiply)
Inches Meters 39.36 (Divide) 39.36 (Multiply)
Inches Rods 96 (Divide) 96 (Multiply)
Inches Furlongs 7920 (Divide) 7920 (Multiply)
Inches Miles 63360 (Divide) 63360 (Multiply)
Yards Meters 1.09 (Divide) 1.09 (Multiply)
Yards Rods 2.66 (Divide) 2.66 (Multiply)
Yards Furlongs 220 (Divide) 220 (Multiply)
Yards Miles 1760 (Divide) 1760 (Multiply)
Meters Rods 2.44 (Divide) 2.44 (Multiply)
Meters Furlongs 201.168 (Divide) 201.168 (Multiply)
Meters Miles 1609.756 (Divide) 1609.756 (Multiply)
Rods Furlongs 82.5 (Divide) 82.5 (Multiply)
Rods Miles 660 (Divide) 660 (Multiply)
Furlongs Miles 8 (Multiply) 8 (Divide)

Conversion Factors for Power

To convert from To Perform operation Conversely,
Horsepower Joules 746 (Multiply) 746 (Divide)
Horsepower Watts 746 (Multiply) 746 (Divide)
Joules Watts 1 (Multiply) 1 (Multiply)

Conversion Factors for Temperature

To convert from To Perform operation Conversely,
Fahrenheit Celsius (F - 32) * 5/9 (1.8 * C) + 32
Fahrenheit Kelvin ((F - 32) * 5/9) + 273.15 ((K - 273.15) * 1.8) + 32
Celsius Kelvin C + 273.15 C - 273.15

Conversion Factors for Volume

To convert from To Perform operation Conversely,
Barrels Cubic Centimeters 42244.6878 (Multiply) 42244.6878 (Divide)
Barrels Cups 672 (Multiply) 672 (Divide)
Barrels Pints 336 (Multiply) 336 (Divide)
Barrels Quarts 168 (Multiply) 168 (Divide)
Barrels Liters 162.75 (Multiply) 162.75 (Divide)
Barrels Gallons 42 (Divide) 42 (Multiply)
Cubic Centimeters Cups 31.43 (Divide) 31.43 (Multiply)
Cubic Centimeters Pints 62.86 (Divide) 62.86 (Multiply)
Cubic Centimeters Quarts 125.72 (Divide) 125.72 (Multiply)
Cubic Centimeters Liters 265.74 (Divide) 265.74 (Multiply)
Cubic Centimeters Gallons 1005.8259 (Divide) 1005.8259 (Multiply)
Gallons Liters 3.785 (Multiply) 3.785 (Divide)
Gallons Quarts 4 (Multiply) 4 (Divide)
Gallons Pints 8 (Multiply) 8 (Divide)
Gallons Cups 16 (Multiply) 16 (Divide)
Liters Quarts 1.03 (Multiply) 1.03 (Divide)
Liters Pints 2.06 (Multiply) 2.06 (Divide)
Liters Cups 4.23 (Multiply) 4.23 (Divide)
Quarts Pints 2 (Multiply) .5 (Multiply)
Quarts Cups 4 (Multiply) .25 (Multiply)
Pints Cups 2 (Divide) .5 (Multiply)

Conversion Factors for Weight

To convert from To Perform operation Conversely,
Metric Tons Tons 1.0973 (Multiply) .911 (Multiply)
Metric Tons Pounds 2187.5 (Multiply) 2187.5 (Divide)
Metric Tons Ounces 35000 (Multiply) 35000 (Divide)
Metric Tons Grams 1000000 (Multiply) 1000000 (Divide)
Tons Pounds 2000 (Multiply) .0005 (Multiply)
Tons Ounces 32000 (Multiply) 32000 (Divide)
Tons Grams 907200 (Multiply) 907200 (Divide)
Pounds Ounces .0625 (Multiply) 16 (Multiply)
Pounds Grams 453.6 (Multiply) .0022 (Multiply)
Ounces Grams 28.35 (Multiply) .035 (Multiply)

So the idea of this is just to have fun. I would put all of the units in a list box. Then I would have six option buttons (one for each different conversion type), which should clear the list boxes and add the new items. I would use six different functions, testing every single possible condition (I could never remain sane if I had to write all this out!). You should test the conditions with the ListIndex property (the selected item) of the list box.

**Note: In case you are not aware, if the conversion factor says to divide, but you prefer to multiply, enter that value into the calculator in windows, then press the 1/X button. You should multiply by that value if you prefer, because that value is the reciprocal. You can press 1/X when the factor says to multiply and you prefer to divide as well.**

Congratulations, you have made it through! I hope you are comfortable using Visual Basic by now. The next section is the advanced section. Now you may proceed there --> Continue.

Page 1 | Page 2 | Page 3 | Page 4 | Page 5 | Page 6 | Page 7 | Page 8 | Page 9 | Page 10 | Page 11

Page 12 | Page 13 | Page 14 | Page 15 | Page 16 | Page 17 | Page 18 | Page 19 | Page 20

Page 21 | Page 22 | Page 23 | Page 24 | Page 25 | Page 26 | Page 27 | Page 28 | Page 29 | Page 30