Cara Membuat Konversi Berat Barang Menggunakan Visual Basic 6.0 (VB6)
https://carakuvb6.blogspot.com/2017/11/cara-membuat-konversi-berat-barang.html
Setiap barang apapun yang kita jumpai dalam kehidupan sehari pasti mempunyai 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), jika kita ditanya dari 25 Kg berapa Ons. Tentunya kita akan berfikir memutar otak atau bahkan mengambil pena dan secarik kertas untuk menghitung, bahkan jika kita masih ragu-ragu dengan hasil perhitungan kita, pasti kita pastikan menggunakan mesin hitung (Calculator).
Nah kali ini admin akan share syintak perhitungan Cara Membuat Konversi Berat Barang menggunakan Visual Basic 6.0. Buka Ms. Visual Basic 6.0 (VB6) buat sebuah project - StandartEXE - form tambahkan pula komponen ComboBox, TextBox dan CommanButton seperti gambar dibawah ini :
Double klik pada Form dan pilih prosedur Form_Load, pastekan syntak dibawah ini
Kemudian buatlah Sub Fungsi perhitungan konversi berat barang dengan nama, terserah agan-agan saja, seperti 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 = ""
Sub RumusKonv()Selanjutnya double klik pada Tombol Proses dan panggil prosedur sub yang baru kita buat diatas dengan syntak
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
Call RumusKonvSimpan dan Jalankan/F5, pilih satuan awal (satuan besar) dan satuan kecil (konversi dari satuan besar), untuk lebih jelasnya seperti gambar dibawah ini
Mudah bukan !!
Bagus terimakasih sangat membantu
ReplyDelete