Cara Membuat Program Konversi Suhu Dengan Vb

Terlebih dahulu buatlah form seperti berikut ini:

Kemudian masukkan source code berikut ini:
Dim Celcius As Single
Dim Reamur As Single
Dim Fahrenheit As Single
Dim Kelvin As Single
Private Sub Command1_Click()
If Option1.Value = True Then
Celcius = Val(Text1.Text)
Reamur = Celcius * 0.8
Fahrenheit = (Celcius * 9 / 5) + 32
Kelvin = Celcius + 273
IsiText
End If
If Option2.Value = True Then
Reamur = Val(Text2.Text)
Celcius = Reamur * 1.25
Fahrenheit = (Celcius * 9 / 5) + 32
Kelvin = Celcius + 273
IsiText
End If
If Option3.Value = True Then
Fahrenheit = Val(Text3.Text)
Celcius = (Fahrenheit – 32) * 5 / 9
Reamur = Celcius * 0.8
Kelvin = Celcius + 273
IsiText
End If
If Option4.Value = True Then
Kelvin = Val(Text4.Text)
Celcius = Kelvin – 273
Reamur = Celcius * 0.8
Fahrenheit = (Celcius * 9 / 5) + 32
IsiText
End If
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then
Text1.Enabled = True
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = False
KosongkanText
End If
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then
Text1.Enabled = False
Text2.Enabled = True
Text3.Enabled = False
Text4.Enabled = False
KosongkanText
End If
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = True
Text4.Enabled = False
KosongkanText
End If
End Sub
Private Sub Option4_Click()
If Option4.Value = True Then
Text1.Enabled = False
Text2.Enabled = False
Text3.Enabled = False
Text4.Enabled = True
KosongkanText
End If
End Sub
Sub KosongkanText()
Text1.Text = “”
Text2.Text = “”
Text3.Text = “”
Text4.Text = “”
End Sub
Sub IsiText()
Text1.Text = Celcius
Text2.Text = Reamur
Text3.Text = Fahrenheit
Text4.Text = Kelvin
End Sub

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s