0% found this document useful (0 votes)
24 views3 pages

Koding Konversi Panjang

The document contains code for a program that converts between different units of length. It populates two combo boxes with various units including km, m, cm, etc. When a conversion is triggered, it checks the values selected in the two combo boxes and performs the appropriate calculation to convert the input value in the first unit to the equivalent value in the second unit. Conversions between all the listed units are supported through nested if/else statements.

Uploaded by

Arum Surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Koding Konversi Panjang

The document contains code for a program that converts between different units of length. It populates two combo boxes with various units including km, m, cm, etc. When a conversion is triggered, it checks the values selected in the two combo boxes and performs the appropriate calculation to convert the input value in the first unit to the equivalent value in the second unit. Conversions between all the listed units are supported through nested if/else statements.

Uploaded by

Arum Surya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Public Class Form1

Sub combo()
With ComboBoxPAwal
.Items.Add("km")
.Items.Add("hm")
.Items.Add("dam")
.Items.Add("m")
.Items.Add("dm")
.Items.Add("cm")
.Items.Add("mm")
End With
With ComboBoxPAkhir
.Items.Add("km")
.Items.Add("hm")
.Items.Add("dam")
.Items.Add("m")
.Items.Add("dm")
.Items.Add("cm")
.Items.Add("mm")
End With
End Sub

Private Sub BtnConvert_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles BtnConvert.Click
If ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "km" Then
TxtPOutput.Text = TxtPInput.Text
ElseIf ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text * 10
ElseIf ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text * 100
ElseIf ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text * 1000
ElseIf ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text * 10000
ElseIf ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text * 100000
ElseIf ComboBoxPAwal.Text = "km" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text * 1000000
End If

If ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "km" Then


TxtPOutput.Text = TxtPInput.Text / 10
ElseIf ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text
ElseIf ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text * 10
ElseIf ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text * 100
ElseIf ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text * 1000
ElseIf ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text * 10000
ElseIf ComboBoxPAwal.Text = "hm" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text * 100000
End If
If ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "km" Then
TxtPOutput.Text = TxtPInput.Text / 100
ElseIf ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text / 10
ElseIf ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text
ElseIf ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text * 10
ElseIf ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text * 100
ElseIf ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text * 1000
ElseIf ComboBoxPAwal.Text = "dam" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text * 10000
End If

If ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "km" Then


TxtPOutput.Text = TxtPInput.Text / 1000
ElseIf ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text / 100
ElseIf ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text / 10
ElseIf ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text
ElseIf ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text * 10
ElseIf ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text * 100
ElseIf ComboBoxPAwal.Text = "m" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text * 1000
End If

If ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "km" Then


TxtPOutput.Text = TxtPInput.Text / 10000
ElseIf ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text / 1000
ElseIf ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text / 100
ElseIf ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text / 10
ElseIf ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text
ElseIf ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text * 10
ElseIf ComboBoxPAwal.Text = "dm" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text * 100
End If

If ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "km" Then


TxtPOutput.Text = TxtPInput.Text / 1000
ElseIf ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text / 100
ElseIf ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text / 10
ElseIf ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text
ElseIf ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text * 10
ElseIf ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text * 100
ElseIf ComboBoxPAwal.Text = "cm" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text * 1000
End If

If ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "km" Then


TxtPOutput.Text = TxtPInput.Text / 1000000
ElseIf ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "hm" Then
TxtPOutput.Text = TxtPInput.Text / 100000
ElseIf ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "dam" Then
TxtPOutput.Text = TxtPInput.Text / 10000
ElseIf ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "m" Then
TxtPOutput.Text = TxtPInput.Text / 1000
ElseIf ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "dm" Then
TxtPOutput.Text = TxtPInput.Text / 100
ElseIf ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "cm" Then
TxtPOutput.Text = TxtPInput.Text / 10
ElseIf ComboBoxPAwal.Text = "mm" And ComboBoxPAkhir.Text = "mm" Then
TxtPOutput.Text = TxtPInput.Text
End If
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
Call combo()
End Sub

End Class

Sub combo()
With ComboBoxPAwal
.Items.Add("meter")
.Items.Add("inch")
.Items.Add("feet")
.Items.Add("yard")
.Items.Add("mile")
End With
With ComboBoxPAkhir
.Items.Add("meter")
.Items.Add("inch")
.Items.Add("feet")
.Items.Add("yard")
.Items.Add("mile")
End With
End Sub

You might also like