Setiap barang apapun yang kita jumpai dalam kehidupan sehari niscaya memiliki satuan berat hanya saja satuan berat tu selalu berbeda antara barang yang satu dan barang yang lain. Katakanlah berat suatu kardus berisi TV 25 Kilogram (Kg), jikalau kita ditanya dari 25 Kg berapa Ons. Tentunya kita akan berfikir memutar otak atau bahkan mengambil pena dan secarik kertas untuk menghitung, bahkan jikalau kita masih ragu-ragu dengan hasil perhitungan kita, niscaya kita pastikan memakai mesin hitung (Calculator).

Nah kali ini admin akan share syintak perhitungan Cara Membuat Konversi Berat Barang memakai Visual Basic 6.0. Buka Ms. Visual Basic 6.0 (VB6) buat sebuah project – StandartEXE – form tambahkan pula komponen ComboBox, TextBox dan CommanButton menyerupai gambar dibawah ini : 
Cara Menciptakan Konversi Berat Barang Memakai Visual Basic 6.0 (Vb6)

Double klik pada Form dan pilih mekanisme Form_Load, pastekan syntak dibawah ini
Combo1.AddItem “Ton”
Combo1.AddItem “Kwintal”
Combo1.AddItem “Kilogram”
Combo1.AddItem “Gram”
Combo1.AddItem “Pound”
Combo1.AddItem “Lb”
Combo1.AddItem “Kip”
Combo1.AddItem “Slug”

Combo2.AddItem “Ton”
Combo2.AddItem “Kwintal”
Combo2.AddItem “Kilogram”
Combo2.AddItem “Gram”
Combo2.AddItem “Pound”
Combo2.AddItem “Lb”
Combo2.AddItem “Kip”
Combo2.AddItem “Slug”

Text1.Text = “”
Text2.Text = “”

Kemudian buatlah Sub Fungsi perhitungan konversi berat barang dengan nama, terserah agan-agan saja, menyerupai dibawah ini : 

Sub RumusKonv()
    If Combo1.Text = “Ton” And Combo2.Text = “Ton” Then
       Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Kwintal” Then
       Text2.Text = Val(Text1.Text) * 10
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Kilogram” Then
       Text2.Text = Val(Text1.Text) * 1000
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Gram” Then
       Text2.Text = Val(Text1.Text) * 10 ^ 6
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Pound” Then
       Text2.Text = (Val(Text1.Text) * 1000) / 0.45359237
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Lb” Then
       Text2.Text = ((Val(Text1.Text) * 1000) / 14.59) / 0.03108
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Kip” Then
       Text2.Text = (((Val(Text1.Text) * 1000) / 14.59) / 0.03108) / 1000
    ElseIf Combo1.Text = “Ton” And Combo2.Text = “Slug” Then
        Text2.Text = (Val(Text1.Text) * 1000) / 14.59
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Ton” Then
        Text2.Text = Val(Text1.Text) / 10
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Kwintal” Then
        Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Kilogram” Then
        Text2.Text = Val(Text1.Text) * 100
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Gram” Then
        Text2.Text = Val(Text1.Text) * 10 ^ 5
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Pound” Then
        Text2.Text = (Val(Text1.Text) * 100) / 0.45359237
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Lb” Then
        Text2.Text = ((Val(Text1.Text) * 100) / 14.59) / 0.03108
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Kip” Then
        Text2.Text = (((Val(Text1.Text) * 100) / 14.59) / 0.03108) / 1000
    ElseIf Combo1.Text = “Kwintal” And Combo2.Text = “Slug” Then
        Text2.Text = (Val(Text1.Text) * 100) / 14.59
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Ton” Then
        Text2.Text = Val(Text1.Text) / 1000
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Kwintal” Then
        Text2.Text = Val(Text1.Text) / 100
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Kilogram” Then
        Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Gram” Then
        Text2.Text = Val(Text1.Text) * 10 ^ 3
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Pound” Then
        Text2.Text = Val(Text1.Text) / 0.45359237
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Lb” Then
        Text2.Text = (Val(Text1.Text) / 14.59) / 0.03108
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Kip” Then
        Text2.Text = (((Val(Text1.Text) / 14.59) / 0.03108) / 1000)
    ElseIf Combo1.Text = “Kilogram” And Combo2.Text = “Slug” Then
        Text2.Text = Val(Text1.Text) / 14.59
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Ton” Then
        Text2.Text = Val(Text1.Text) / 10 ^ 6
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Kwintal” Then
        Text2.Text = Val(Text1.Text) * 10 ^ -5
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Kilogram” Then
        Text2.Text = Val(Text1.Text) * 10 ^ -3
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Gram” Then
        Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Pound” Then
        Text2.Text = (Val(Text1.Text) * 10 ^ -3) / 0.45359237
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Lb” Then
        Text2.Text = ((Val(Text1.Text) * 10 ^ -3) / 14.59) / 0.03108
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Kip” Then
        Text2.Text = (((Val(Text1.Text) * 10 ^ -3) / 14.59) / 0.03108) / 1000
    ElseIf Combo1.Text = “Gram” And Combo2.Text = “Slug” Then
        Text2.Text = (Val(Text1.Text) * 10 ^ -3) / 14.59
   
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Ton” Then
        Text2.Text = (Val(Text1.Text) * 0.45359237) * 10 ^ -3
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Kwintal” Then
        Text2.Text = (Val(Text1.Text) * 0.45359237) * 10 ^ -2
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Kilogram” Then
        Text2.Text = Val(Text1.Text) * 0.45359237
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Gram” Then
        Text2.Text = (Val(Text1.Text) * 0.45359237) * 10 ^ 3
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Pound” Then
        Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Lb” Then
        Text2.Text = ((Val(Text1.Text) * 0.45359237) / 14.59) / 0.03108
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Kip” Then
        Text2.Text = (((Val(Text1.Text) * 0.45359237) / 14.59) / 0.03108) / 1000
    ElseIf Combo1.Text = “Pound” And Combo2.Text = “Slug” Then
        Text2.Text = (Val(Text1.Text) * 0.45359237) / 14.59
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Ton” Then
        Text2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) * 10 ^ 3
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Kwintal” Then
        Text2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) * 10 ^ 2
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Kilogram” Then
        Text2.Text = (Val(Text1.Text) * 0.03108) * 14.59
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Gram” Then
        Text2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) * 10 ^ -3
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Pound” Then
        Text2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) / 0.45359237
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Lb” Then
        Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Kip” Then
        Text2.Text = Val(Text1.Text) / 1000
    ElseIf Combo1.Text = “Lb” And Combo2.Text = “Slug” Then
        Text2.Text = Val(Text1.Text) * 0.03108
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Ton” Then
        Text2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 10 ^ -3
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Kwintal” Then
        Text2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 10 ^ -2
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Kilogram” Then
        Text2.Text = ((Val(Text1.Text) * 1000) * 0.03108) * 14.59
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Gram” Then
        Text2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 10 ^ 3
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Pound” Then
        Text2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 0.45359237
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Lb” Then
        Text2.Text = Val(Text1.Text) * 1000
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Kip” Then
        Text2.Text = Text1.Text
    ElseIf Combo1.Text = “Kip” And Combo2.Text = “Slug” Then
        Text2.Text = (Val(Text1.Text) * 1000) * 0.03108
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Ton” Then
        Text2.Text = (Val(Text1.Text) * 14.59) * 10 ^ -3
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Kwintal” Then
        Text2.Text = (Val(Text1.Text) * 14.59) * 10 ^ -2
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Kilogram” Then
        Text2.Text = Val(Text1.Text) * 14.59
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Gram” Then
        Text2.Text = (Val(Text1.Text) * 14.59) * 10 ^ 3
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Pound” Then
        Text2.Text = (Val(Text1.Text) * 14.59) / 0.45359273
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Lb” Then
        Text2.Text = Val(Text1.Text) / 0.03108
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Kip” Then
        Text2.Text = (Val(Text1.Text) / 0.03108) / 1000
    ElseIf Combo1.Text = “Slug” And Combo2.Text = “Slug” Then
        Text2.Text = Text1.Text
    End If
End Sub

 Selanjutnya double klik pada Tombol Proses dan panggil mekanisme sub yang gres kita buat diatas dengan syntak 

Call RumusKonv 

Simpan dan Jalankan/F5, pilih satuan awal (satuan besar) dan satuan kecil (konversi dari satuan besar), untuk lebih jelasnya menyerupai gambar dibawah ini

Cara Menciptakan Konversi Berat Barang Memakai Visual Basic 6.0 (Vb6)

 Mudah bukan !!