1.Buka aplikasi Microsoft visual basic 2010 express ->file->New Project->Windows Form Application, isikan namanya Konversi Panjang. Kemudian klik ok.
Rename nama formnya menjadi Main Menu. Buat tampilan formnya seperti ini
Kemudian masukan code berikut ini : Untuk button Convert to meters .
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Meters.Show()
End Sub
Untuk button Convert to inches.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Inches.Show()
End Sub
Untuk button Exit.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
2.Kemudian kita membuat satu form baru dengan cara klik kanan di project kita pilih add -> windows form. Isikan namanya Meters. Lalu buat tampilan formnya seperti ini.
Kemudian masukan code berikut ini : Untuk button Convert To Inches.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dblMeters As Double
Dim dblInches As Double
Try
dblMeters = CDbl(txtMeters.Text)
dblInches = MeterToInches(dblMeters)
MessageBox.Show(dblMeters.ToString() & "Meter Equals" & dblInches.ToString() & " Inches")
Catch
MessageBox.Show("Error : Enter a Numeric Value.")
End Try
End Sub
Untuk button Convert To Feet.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dblMeters As Double
Dim dblFeet As Double
Try
dblMeters = CDbl(txtMeters.Text)
dblFeet = MeterToFeet(dblMeters)
MessageBox.Show(dblMeters.ToString() & "Meter Equals" & dblFeet.ToString() & " Feets")
Catch
MessageBox.Show("Error : Enter a Numeric Value.")
End Try
End Sub
Untuk button Convert To Yard.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim dblMeters As Double
Dim dblYards As Double
Try
dblMeters = CDbl(txtMeters.Text)
dblYards = MeterToYard(dblMeters)
MessageBox.Show(dblMeters.ToString() & "Meter Equals" & dblYards.ToString() & " Yards")
Catch
MessageBox.Show("Error : Enter a Numeric Value.")
End Try
End Sub
Untuk button Exit.
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
3.kita buat satu form baru lagi dengan cara klik kanan di project kita pilih add -> windows form. Isikan namanya Inches. Lalu buat tampilan formnya seperti berikut ini.
Masukan code berikut di masing-masing button. Untuk button Convert To Mili Meters.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim dblInches As Double
Dim dblMiliMeters As Double
Try
dblInches = CDbl(txtInches.Text)
dblMiliMeters = InchesToMiliMeters(dblInches)
MessageBox.Show(dblInches.ToString() & "Inch Equals" & dblMiliMeters.ToString() & " MiliMeters")
Catch
MessageBox.Show("Error : Enter a Numeric Value.")
End Try
End Sub
Untuk button Convert To Centi Meters.
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim dblInches As Double
Dim dblCentiMeters As Double
Try
dblInches = CDbl(txtInches.Text)
dblCentiMeters = InchesToCentiMeters(dblInches)
MessageBox.Show(dblInches.ToString() & "Inch Equals" & dblCentiMeters.ToString() & " CentiMeters")
Catch
MessageBox.Show("Error : Enter a Numeric Value.")
End Try
End Sub
Untuk button Convert To Meters.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim dblInches As Double
Dim dblMeters As Double
Try
dblInches = CDbl(txtInches.Text)
dblMeters = InchesToMeters(dblInches)
MessageBox.Show(dblInches.ToString() & "Inch Equals" & dblMeters.ToString() & " Meters")
Catch
MessageBox.Show("Error : Enter a Numeric Value.")
End Try
End Sub
Untuk button Exit.
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Me.Close()
End Sub
4.Buat sebuah module dengan cara klik kanan pada project kita pilih add-> Module. Lalu ketikan code berikut ini.
5.Setelah semua selesai run programnya.