Kamis, 02 Oktober 2014

“Konversi Suhu” dengan Visual Basic 6.0

VB6SP6_logo

Latihan “Konversi Suhu” yang terdapat pada eBook “Panduan Praktik Pemrograman Komputer”.

Tidak banyak modifikasi yang dibuat. Hanya sekedar menambahkan fitur tombol “Baru”. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan.

 

 

Konversi_Suhu

VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.1#0"; "MSCOMCTL.OCX"
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Konversi Suhu"
ClientHeight = 4365
ClientLeft = 45
ClientTop = 405
ClientWidth = 4455
BeginProperty Font
Name = "Segoe UI"
Size = 9
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4365
ScaleWidth = 4455
StartUpPosition = 2 'CenterScreen
Begin MSComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 495
Left = 0
TabIndex = 11
Top = 3870
Visible = 0 'False
Width = 4455
_ExtentX = 7858
_ExtentY = 873
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin VB.Frame Frame1
Caption = "Hasil Konversi:"
Height = 1935
Left = 240
TabIndex = 4
Top = 1440
Width = 3975
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 1
Left = 1800
Locked = -1 'True
TabIndex = 7
Top = 360
Width = 1815
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 2
Left = 1800
Locked = -1 'True
TabIndex = 6
Top = 840
Width = 1815
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 3
Left = 1800
Locked = -1 'True
TabIndex = 5
Top = 1320
Width = 1815
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Derajat Reamur:"
Height = 225
Index = 1
Left = 240
TabIndex = 10
Top = 420
Width = 1260
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Derajat Kelvins:"
Height = 225
Index = 2
Left = 240
TabIndex = 9
Top = 900
Width = 1200
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Derajat Fahrenheit:"
Height = 225
Index = 3
Left = 240
TabIndex = 8
Top = 1380
Width = 1485
End
End
Begin VB.CommandButton Command1
Caption = "K&eluar"
Height = 495
Index = 1
Left = 2400
TabIndex = 3
Top = 3720
Width = 1815
End
Begin VB.CommandButton Command1
Caption = "Konversi"
Enabled = 0 'False
Height = 495
Index = 0
Left = 240
TabIndex = 2
Top = 840
Width = 3975
End
Begin VB.TextBox Text1
Alignment = 1 'Right Justify
BeginProperty Font
Name = "Segoe UI"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 1560
TabIndex = 1
Top = 240
Width = 2655
End
Begin VB.Line Line1
Index = 0
X1 = 240
X2 = 4200
Y1 = 3600
Y2 = 3600
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Derajat Celcius:"
Height = 225
Index = 0
Left = 240
TabIndex = 0
Top = 300
Width = 1215
End
Begin VB.Line Line1
BorderColor = &H00FFFFFF&
BorderWidth = 4
Index = 1
X1 = 240
X2 = 4200
Y1 = 3600
Y2 = 3600
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
If Command1(Index).Caption = "Konversi" Then
Dim Celcius, Reamur, Kelvin, Fahrenheit
Celcius = Text1(0).Text
Reamur = 4 / 5 * Celcius
Kelvin = Celcius + 273
Fahrenheit = (9 / 5 * Celcius) + 32
Text1(1).Text = Reamur
Text1(2).Text = Kelvin
Text1(3).Text = Fahrenheit
Command1(Index).Caption = "Baru"
Command1(Index).SetFocus
Else
Dim i%
For i = 0 To 3
Text1(i).Text = Empty
Next
Text1(Index).SetFocus
Command1(Index).Caption = "Konversi"
End If
Case 1:
Unload Me
End Select
End Sub

Private Sub Form_Unload(Cancel As Integer)
If MsgBox("Keluar program ?", vbQuestion + vbYesNo, "Perhatian") = vbNo Then
Cancel = 1
End If
End Sub

Private Sub Text1_Change(Index As Integer)
If Text1(0).Text = Empty Then
Command1(0).Enabled = False
Else
Command1(0).Enabled = True
End If
End Sub

Private Sub Text1_KeyPress(Index As Integer, KeyAscii As Integer)
If Not (KeyAscii >= Asc("0") And KeyAscii <= Asc("9") Or _
KeyAscii = vbKeyBack Or KeyAscii = vbKeyReturn) Then
Beep
KeyAscii = 0
End If

If (KeyAscii = 13) Then
Command1_Click (0)
End If
End Sub


Unduh Kode Sumber

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda