Konversi Jarak Dengan VB


Option Explicit

Dim unit( ),konstant( )

—————————–

Private sub cmdConvert_Click()

Dim nMeter as double

Dim nLength 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s