by Peter Elisa Souhoka (21 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 16th May 2008
Date Added: Mon 8th February 2021
Rating:
(1 Votes)
Konversi Unit
Dim unit(), Konstant()
Private Sub cmdConvert_Click()
Dim nMeter As Double
Dim nLength As Double
Dim nHasil As Double
nLength = Val(Trim(txtLength.Text))
nMeter = nLength * Konstant(cmbAsal.ListIndex)
nHasil = nMeter / Konstant(cmbTujuan.ListIndex)
lblHasil.Caption = Str(nHasil) & " " & cmbTujuan.Text
End Sub
Private Sub Form_Load()
Dim i As Long
unit = Array("Angstrom", "Nanometer", "Micrometer", _
"Milimeter", "Centimeter", "Inchi", "Feet", "Yard", _
"Meter", "Kilometer", "Mil", "Nautical Mile", _
"Astronomical Unit", "Light Year", "Parsecs")
Konstant = Array(0.0000000001, 0.000000001, 0.000001, _
0.001, 0.01, 0.0254, 0.3048, 0.9144, _
1, 1000, 1609.344, 1852, _
149597870000#, 9.4607304725808E+15, 1.95141573788288E+21)
cmbAsal.Clear
cmbTujuan.Clear
For i = 0 To 14
cmbAsal.AddItem unit(i)
cmbTujuan.AddItem unit(i)
Next i
cmbAsal.ListIndex = 8
cmbTujuan.ListIndex = 8
End Sub