Hello,
I'm new to the forums, so hello. I have a quick question in regards to a metric conversion program I am working on. The code as is follows:
Say you enter the following:Code:Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
Dim miles As Integer
Dim yards As Integer
Dim feet As Integer
Dim inches As Integer
Dim meters As Integer
Dim kilometers As Integer
Dim centimeters As Double
Dim totalInches As Integer
miles = CInt(txtMiles.Text)
yards = CInt(txtYards.Text)
feet = CInt(txtFeet.Text)
inches = CInt(txtInches.Text)
totalInches = 63360 * miles + 36 * yards + 12 * feet + inches
meters = (totalInches / 39.37)
kilometers = Int(meters / 1000)
centimeters = (meters / 100)
With lstBoxResults.Items
.Clear()
.Add("The metric length is:")
.Add(kilometers & " kilometers")
.Add(meters & " meters")
.Add(centimeters & " centimeters")
End With
Miles: 5
Yards: 20
Feet: 2
Inches: 4
The output is as follows:
The metric length is:
8 kilometers (this is correct)
8066 meters (should be 65 meters)
80.66 meters (should be 73.50 meters)
Any help would be much appreciated. Thanks!