Saturday 23 June 2012

Cara Membuat Program Untuk Mencari Konversi Suhu di Visual Basic 6.0


Hello sob.. Ketemu lagi nih sama saya…

Untuk kali ini saya akan membuat program yang bisa mencari konversi suhu….

Oke kita langsung saja….
Pertama kita buka Visual Basic 6.0-nya :





Dan tambahkan Component-component-nya :  1 Frame5 Label, 5 Textbox, 4 OptionButton, dan 3 CommandButton.
Lalu atur posisinya seperti berikut :



 
--Pengaturan Properties :

Object
Properties
Nilai
Form1
Caption
StartUpPosition
Konversi Suhu
2 – CenterScreen
Frame1
Caption
Masukkan pilihan input
Label1
Caption
Masukkan Suhu yang Telah Diketahui dan Tekan Tombol Konversi
Label2
Caption
Fahrenhei :
Label3
Caption
Celcius :
Label4
Caption
Rheamur :
Label5
Caption
Kelvin :
Option1
Caption
Fahrenhei
Option2
Caption
Celcius
Option3
Caption
Rheamur
Option4
Caption
Kelvin
Text1, Text2, Text3, Text4, dan Text5
Text
(Kosong)
Command1
Caption
&Konversi
Command2
Caption
&Again
Command3
Caption
&Exit


--Dan tulislah Coding di Form1 :
Option1 = True


--Coding di Option1 :
If Option1 = True Then
Option2 = False And Option3 = False And Option4 = False
End If


--Coding di Command1 :
Dim jwb As Integer
If 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.Show
End If
ElseIf Option1 = True Then
Fahrenheit
ElseIf Option2 = True Then
Celcius
ElseIf Option3 = True Then
Rheamur
ElseIf Option4 = True Then
Kelvin
End If


--Coding di Command2 :
Text1 = ""
Text2 = ""
Text3 = ""
Text4 = ""
Text5 = ""
Text2.BackColor = "&H80000005"
Text3.BackColor = "&H80000005"
Text4.BackColor = "&H80000005"
Text5.BackColor = "&H80000005"
Text1.SetFocus


--Coding di Command3 :
Unload Me


--Dan yang terakhir, tulislah Coding ini di paling bawah dari Coding yang lain :
Sub Celcius()
Dim bil1, fah, rhe, kel As Integer
bil1 = Text1
fah = Val((Text1.Text) * 9 / 5) + 32
Text2.Text = FormatNumber(fah, 2, vbFalse, vbFalse, vbFalse)
rhe = Val(Text1.Text) * 4 / 5
Text4.Text = FormatNumber(rhe, 2, vbFalse, vbFalse, vbFalse)
kel = Val(Text1.Text) + 273
Text5.Text = FormatNumber(kel, 2, vbFalse, vbFalse, vbFalse)
Text3.BackColor = black
End Sub

Sub Fahrenheit()
Dim bil1, cel, rhe, kel As Integer
bil1 = Text1
cel = Val((Text1.Text) - 32) * 5 / 9
Text3.Text = FormatNumber(cel, 2, vbFalse, vbFalse, vbFalse)
rhe = Val((Text1.Text) - 32) * 4 / 9
Text4.Text = FormatNumber(rhe, 2, vbFalse, vbFalse, vbFalse)
kel = Val(((Text1.Text) - 32) * 5 / 9) + 273
Text5.Text = FormatNumber(kel, 2, vbFalse, vbFalse, vbFalse)
Text2.BackColor = black
End Sub

Sub Rheamur()
Dim bil1, fah, cel, kel As Integer
bil1 = Text1
fah = Val((Text1.Text) * 9 / 4) + 32
Text2.Text = FormatNumber(fah, 2, vbFalse, vbFalse, vbFalse)
cel = Val(Text1.Text) * 5 / 4
Text3.Text = FormatNumber(cel, 2, vbFalse, vbFalse, vbFalse)
kel = Val((Text1.Text) * 5 / 4) + 273
Text5.Text = FormatNumber(kel, 2, vbFalse, vbFalse, vbFalse)
Text4.BackColor = black
End Sub

Sub Kelvin()
Dim bil1, fah, cel, rhe As Integer
bil1 = Text1
fah = Val((((Text1.Text) - 273) * 9 / 5)) + 32
Text2.Text = FormatNumber(fah, 2, vbFalse, vbFalse, vbFalse)
cel = Val(Text1.Text) - 273
Text3.Text = FormatNumber(cel, 2, vbFalse, vbFalse, vbFalse)
rhe = Val((Text1.Text) - 273) * 4 / 5
Text4.Text = FormatNumber(rhe, 2, vbFalse, vbFalse, vbFalse)
Text5.BackColor = black
End Sub



Setelah itu kita coba jalankan programnya / di Running (F5), dan selesai.

Gimana sob…. program yang bagus kan… kalau sobat sekalian pengen yang udah jadi, download saja programnya dibawah ini :

No comments:

Post a Comment

Komentar, pesan, kritik, dan saran...