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
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" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Ton" And Combo2.Text = "Kwintal" ThenText2.Text = Val(Text1.Text) * 10ElseIf Combo1.Text = "Ton" And Combo2.Text = "Kilogram" ThenText2.Text = Val(Text1.Text) * 1000ElseIf Combo1.Text = "Ton" And Combo2.Text = "Gram" ThenText2.Text = Val(Text1.Text) * 10 ^ 6ElseIf Combo1.Text = "Ton" And Combo2.Text = "Pound" ThenText2.Text = (Val(Text1.Text) * 1000) / 0.45359237ElseIf Combo1.Text = "Ton" And Combo2.Text = "Lb" ThenText2.Text = ((Val(Text1.Text) * 1000) / 14.59) / 0.03108ElseIf Combo1.Text = "Ton" And Combo2.Text = "Kip" ThenText2.Text = (((Val(Text1.Text) * 1000) / 14.59) / 0.03108) / 1000ElseIf Combo1.Text = "Ton" And Combo2.Text = "Slug" ThenText2.Text = (Val(Text1.Text) * 1000) / 14.59ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Ton" ThenText2.Text = Val(Text1.Text) / 10ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Kwintal" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Kilogram" ThenText2.Text = Val(Text1.Text) * 100ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Gram" ThenText2.Text = Val(Text1.Text) * 10 ^ 5ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Pound" ThenText2.Text = (Val(Text1.Text) * 100) / 0.45359237ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Lb" ThenText2.Text = ((Val(Text1.Text) * 100) / 14.59) / 0.03108ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Kip" ThenText2.Text = (((Val(Text1.Text) * 100) / 14.59) / 0.03108) / 1000ElseIf Combo1.Text = "Kwintal" And Combo2.Text = "Slug" ThenText2.Text = (Val(Text1.Text) * 100) / 14.59ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Ton" ThenText2.Text = Val(Text1.Text) / 1000ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Kwintal" ThenText2.Text = Val(Text1.Text) / 100ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Kilogram" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Gram" ThenText2.Text = Val(Text1.Text) * 10 ^ 3ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Pound" ThenText2.Text = Val(Text1.Text) / 0.45359237ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Lb" ThenText2.Text = (Val(Text1.Text) / 14.59) / 0.03108ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Kip" ThenText2.Text = (((Val(Text1.Text) / 14.59) / 0.03108) / 1000)ElseIf Combo1.Text = "Kilogram" And Combo2.Text = "Slug" ThenText2.Text = Val(Text1.Text) / 14.59ElseIf Combo1.Text = "Gram" And Combo2.Text = "Ton" ThenText2.Text = Val(Text1.Text) / 10 ^ 6ElseIf Combo1.Text = "Gram" And Combo2.Text = "Kwintal" ThenText2.Text = Val(Text1.Text) * 10 ^ -5ElseIf Combo1.Text = "Gram" And Combo2.Text = "Kilogram" ThenText2.Text = Val(Text1.Text) * 10 ^ -3ElseIf Combo1.Text = "Gram" And Combo2.Text = "Gram" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Gram" And Combo2.Text = "Pound" ThenText2.Text = (Val(Text1.Text) * 10 ^ -3) / 0.45359237ElseIf Combo1.Text = "Gram" And Combo2.Text = "Lb" ThenText2.Text = ((Val(Text1.Text) * 10 ^ -3) / 14.59) / 0.03108ElseIf Combo1.Text = "Gram" And Combo2.Text = "Kip" ThenText2.Text = (((Val(Text1.Text) * 10 ^ -3) / 14.59) / 0.03108) / 1000ElseIf Combo1.Text = "Gram" And Combo2.Text = "Slug" ThenText2.Text = (Val(Text1.Text) * 10 ^ -3) / 14.59ElseIf Combo1.Text = "Pound" And Combo2.Text = "Ton" ThenText2.Text = (Val(Text1.Text) * 0.45359237) * 10 ^ -3ElseIf Combo1.Text = "Pound" And Combo2.Text = "Kwintal" ThenText2.Text = (Val(Text1.Text) * 0.45359237) * 10 ^ -2ElseIf Combo1.Text = "Pound" And Combo2.Text = "Kilogram" ThenText2.Text = Val(Text1.Text) * 0.45359237ElseIf Combo1.Text = "Pound" And Combo2.Text = "Gram" ThenText2.Text = (Val(Text1.Text) * 0.45359237) * 10 ^ 3ElseIf Combo1.Text = "Pound" And Combo2.Text = "Pound" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Pound" And Combo2.Text = "Lb" ThenText2.Text = ((Val(Text1.Text) * 0.45359237) / 14.59) / 0.03108ElseIf Combo1.Text = "Pound" And Combo2.Text = "Kip" ThenText2.Text = (((Val(Text1.Text) * 0.45359237) / 14.59) / 0.03108) / 1000ElseIf Combo1.Text = "Pound" And Combo2.Text = "Slug" ThenText2.Text = (Val(Text1.Text) * 0.45359237) / 14.59ElseIf Combo1.Text = "Lb" And Combo2.Text = "Ton" ThenText2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) * 10 ^ 3ElseIf Combo1.Text = "Lb" And Combo2.Text = "Kwintal" ThenText2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) * 10 ^ 2ElseIf Combo1.Text = "Lb" And Combo2.Text = "Kilogram" ThenText2.Text = (Val(Text1.Text) * 0.03108) * 14.59ElseIf Combo1.Text = "Lb" And Combo2.Text = "Gram" ThenText2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) * 10 ^ -3ElseIf Combo1.Text = "Lb" And Combo2.Text = "Pound" ThenText2.Text = ((Val(Text1.Text) * 0.03108) * 14.59) / 0.45359237ElseIf Combo1.Text = "Lb" And Combo2.Text = "Lb" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Lb" And Combo2.Text = "Kip" ThenText2.Text = Val(Text1.Text) / 1000ElseIf Combo1.Text = "Lb" And Combo2.Text = "Slug" ThenText2.Text = Val(Text1.Text) * 0.03108ElseIf Combo1.Text = "Kip" And Combo2.Text = "Ton" ThenText2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 10 ^ -3ElseIf Combo1.Text = "Kip" And Combo2.Text = "Kwintal" ThenText2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 10 ^ -2ElseIf Combo1.Text = "Kip" And Combo2.Text = "Kilogram" ThenText2.Text = ((Val(Text1.Text) * 1000) * 0.03108) * 14.59ElseIf Combo1.Text = "Kip" And Combo2.Text = "Gram" ThenText2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 10 ^ 3ElseIf Combo1.Text = "Kip" And Combo2.Text = "Pound" ThenText2.Text = (((Val(Text1.Text) * 1000) * 0.03108) * 14.59) / 0.45359237ElseIf Combo1.Text = "Kip" And Combo2.Text = "Lb" ThenText2.Text = Val(Text1.Text) * 1000ElseIf Combo1.Text = "Kip" And Combo2.Text = "Kip" ThenText2.Text = Text1.TextElseIf Combo1.Text = "Kip" And Combo2.Text = "Slug" ThenText2.Text = (Val(Text1.Text) * 1000) * 0.03108ElseIf Combo1.Text = "Slug" And Combo2.Text = "Ton" ThenText2.Text = (Val(Text1.Text) * 14.59) * 10 ^ -3ElseIf Combo1.Text = "Slug" And Combo2.Text = "Kwintal" ThenText2.Text = (Val(Text1.Text) * 14.59) * 10 ^ -2ElseIf Combo1.Text = "Slug" And Combo2.Text = "Kilogram" ThenText2.Text = Val(Text1.Text) * 14.59ElseIf Combo1.Text = "Slug" And Combo2.Text = "Gram" ThenText2.Text = (Val(Text1.Text) * 14.59) * 10 ^ 3ElseIf Combo1.Text = "Slug" And Combo2.Text = "Pound" ThenText2.Text = (Val(Text1.Text) * 14.59) / 0.45359273ElseIf Combo1.Text = "Slug" And Combo2.Text = "Lb" ThenText2.Text = Val(Text1.Text) / 0.03108ElseIf Combo1.Text = "Slug" And Combo2.Text = "Kip" ThenText2.Text = (Val(Text1.Text) / 0.03108) / 1000ElseIf Combo1.Text = "Slug" And Combo2.Text = "Slug" ThenText2.Text = Text1.TextEnd IfEnd 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
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