Source Code Konversi Berat Menggunakan Visual Basic 6 (VB6)

Baca Juga :
Terkadang kita menghadapi sebuah masalah dalam perhitungan berat barang, apalagi jika barang tersebut mempunyai beberapa satuan berat, misalkan 145 Kg Berapa Ons. Akan sangat membingungkan bukan jika kita harus berfikir dan membutuhkan waktu relatif lama untuk mulai menghitung dari per 1 Kg Berapa Ons. Sedangkan pada saat ini yang kita butuhkan cepat, tepat dan akurat. Untuk mengatasi masalah tersebut admin akan sedikit share sebuah Source Code sangat mudah tentang konversi berat barang.

Buka Visual Basic 6.0 buatlah sebuah form dan tambahkan beberapa komponen pendukung seperti 
1. ComboBox
2. CommandButton
3. TextBox

Source Code Konversi Berat Menggunakan Visual Basic 6 (VB6)

Selanjutnya double klik pada form kemudian pilih prosedur Form_Load dan pastekan coding 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 buat Sub seperti 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
Kemudian double klik pada CommandButton dan panggil Sub diatas dengan coding seperti dibawah ini
Call RumusKonv
Yang terakhir Save kemudian Run, dan layout dari source code diatas seperti gambar di bawah ini


Source Code Konversi Berat Menggunakan Visual Basic 6 (VB6)

Subscribe untuk berlangganan artikel :

0 Response to "Source Code Konversi Berat Menggunakan Visual Basic 6 (VB6)"

Post a Comment

1. Dilarang menjadikan referensi tanpa mencantumkan sumbernya
2. Berkomentar yang relevan sesuai artikel
3. Gunakan bahasa yang baik dan santun