Wah malem-malem begini saya baru teringat, bahwa ada tugas di esok hari yaitu membuat program konversi suhu dengan Visual Basic. Saya masih awam sekali dalam pemrograman, jadinya saya langsung menuju mbah Google untuk mencari cara membuat program tersebut. Dan langsung ketemu, ini dia tempatnya All Info For You (Terima kasih kepada agan yang punya web)
Ini dia prosedur pembuatannya (copas dari yang punya website):
Buka Visual Basic 6.0 teman-teman dan ikuti langkah-langkah berikut :
- Masukkan 5 buah Label
- Masukkan 1 buah Frame
- Masukkan 5 buah TextBox
- Masukkan 4 buah OptionButton
- Masukkan 3 buah CommandButton
- Label1 Menjadi “Masukkan Suhu yang Telah Diketahui dan Tekan Tombol Konversi” atau sesuka teman-teman.
- Label2 Menjadi “Fahrenheit”
- Label3 Menjadi “Celcius”
- Label4 Menjadi “Rheamur”
- Label5 Menjadi “Kelvin”
- Frame1 Menjadi “Masukkan Pilihan Input”
- OptionButton1 Menjadi “Fahrenheit”
- OptionButton2 Menjadi “Celcius”
- OptionButton3 Menjadi “Rheamur”
- OptionButton4 Menjadi “Kelvin”
- CommandButton1 Menjadi “&Konversi”
- CommandButton2 Menjadi “&Again”
- CommandButton3 Menjadi “&Exit”
| Gambar Program |
Setelah Tampilannya sesuai dengan gambar diatas, maka teman-teman perlu source code atau script agar programnya bisa digunakan.
Inilah Script programnya :
1. Pada Form load
Private Sub Form_Load()Option1 = TrueEnd Sub |
Private Sub Option1_Click()If Option1 = True ThenOption2 = False And Option13 = False And Option4 = FalseEnd IfEnd Sub |
Private Sub Command1_Click()Dim jwb As IntegerIf Text1.Text = "" Then jwb = MsgBox("Masukkan Nilai Suhu Yang Akan Dikonversi!!! ", _ vbInformation + vbYesNo, "WARNING") If jwb = vbNo Then Unload Me ElseIf jwb = vbYes Then FrmKonversiSuhu.ShowEnd IfElseIf Option1 = True ThenFahrenheitElseIf Option2 = True ThenCelciusElseIf Option3 = True ThenRheamurElseIf Option4 = True ThenKelvinEnd IfEnd Sub |
Private Sub Command2_Click()Text1 = ""Text2 = ""Text3 = ""Text4 = ""Text5 = ""Text2.BackColor = "&H80000005"Text3.BackColor = "&H80000005"Text4.BackColor = "&H80000005"Text5.BackColor = "&H80000005"Text1.SetFocusEnd Sub |
Private Sub Command3_Click()Unload MeEnd Sub |
Sub Celcius()Dim bil1, fah, rhe, kel As Integerbil1 = Text1fah = Val((Text1.Text) * 9 / 5) + 32Text2.Text = FormatNumber(fah, 2, vbFalse, vbFalse, vbFalse)rhe = Val(Text1.Text) * 4 / 5Text4.Text = FormatNumber(rhe, 2, vbFalse, vbFalse, vbFalse)kel = Val(Text1.Text) + 273Text5.Text = FormatNumber(kel, 2, vbFalse, vbFalse, vbFalse)Text3.BackColor = blackEnd SubSub Fahrenheit()Dim bil1, cel, rhe, kel As Integerbil1 = Text1cel = Val((Text1.Text) - 32) * 5 / 9Text3.Text = FormatNumber(cel, 2, vbFalse, vbFalse, vbFalse)rhe = Val((Text1.Text) - 32) * 4 / 9Text4.Text = FormatNumber(rhe, 2, vbFalse, vbFalse, vbFalse)kel = Val(((Text1.Text) - 32) * 5 / 9) + 273Text5.Text = FormatNumber(kel, 2, vbFalse, vbFalse, vbFalse)Text2.BackColor = blackEnd SubSub Rheamur()Dim bil1, fah, cel, kel As Integerbil1 = Text1fah = Val((Text1.Text) * 9 / 4) + 32Text2.Text = FormatNumber(fah, 2, vbFalse, vbFalse, vbFalse)cel = Val(Text1.Text) * 5 / 4Text3.Text = FormatNumber(cel, 2, vbFalse, vbFalse, vbFalse)kel = Val((Text1.Text) * 5 / 4) + 273Text5.Text = FormatNumber(kel, 2, vbFalse, vbFalse, vbFalse)Text4.BackColor = blackEnd SubSub Kelvin()Dim bil1, fah, cel, rhe As Integerbil1 = Text1fah = Val((((Text1.Text) - 273) * 9 / 5)) + 32Text2.Text = FormatNumber(fah, 2, vbFalse, vbFalse, vbFalse)cel = Val(Text1.Text) - 273Text3.Text = FormatNumber(cel, 2, vbFalse, vbFalse, vbFalse)rhe = Val((Text1.Text) - 273) * 4 / 5Text4.Text = FormatNumber(rhe, 2, vbFalse, vbFalse, vbFalse)Text5.BackColor = blackEnd Sub
Selesai deh programnya, tinggal teman-teman save...
Sumber:
All Info For You |

Oke gan, lanjutkan :D
BalasHapusSama-sama kita belajar hehe
@Idham: iya agan Idham sipsip. Dan pada akhirnya saya ga' masuk kuliah tadi pagi. Hahaha. Sesuatu sekali jadinya :D
Hapus