Jumat, 03 Oktober 2014

“Piramida String” dengan Visual Basic 6.0

VB6SP6_logo

Percontohan “Aplikasi Struktur Kontrol Perulangan” yang terdapat pada blog “Ketik Visual Basic!”.

Tidak ada banyak modifikasi yang dibuat. Hanya sekedar menambahkan perulangan dengan Angka. Untuk lebih lengkapnya dapat dilihat pada kode sumber yang disertakan

 

 

Piramida_String

VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Piramida String"
ClientHeight = 3975
ClientLeft = 45
ClientTop = 405
ClientWidth = 4905
BeginProperty Font
Name = "Segoe UI"
Size = 9.75
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3975
ScaleWidth = 4905
StartUpPosition = 2 'CenterScreen
Begin VB.CommandButton Command1
Caption = "K&eluar"
Height = 495
Left = 3480
TabIndex = 7
Top = 3360
Width = 1215
End
Begin VB.Frame Frame1
Height = 2175
Left = 2880
TabIndex = 2
Top = 120
Width = 1815
Begin VB.PictureBox Picture1
BorderStyle = 0 'None
Height = 1695
Left = 240
ScaleHeight = 1695
ScaleWidth = 1335
TabIndex = 3
Top = 360
Width = 1335
Begin VB.OptionButton Option1
Caption = "Karakter"
Height = 495
Index = 0
Left = 0
TabIndex = 6
Top = -120
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "Huruf"
Height = 495
Index = 1
Left = 0
TabIndex = 5
Top = 480
Width = 1215
End
Begin VB.OptionButton Option1
Caption = "Angka"
Height = 495
Index = 2
Left = 0
TabIndex = 4
Top = 1080
Width = 1215
End
End
End
Begin VB.CheckBox Check1
Caption = "Terbalik"
Height = 495
Left = 3120
TabIndex = 1
Top = 2520
Width = 1215
End
Begin VB.TextBox Text1
Alignment = 2 'Center
BeginProperty Font
Name = "Segoe UI"
Size = 18
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 2775
Left = 240
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 0
TabStop = 0 'False
Top = 240
Width = 2415
End
Begin VB.Line Line1
Index = 0
X1 = 240
X2 = 4680
Y1 = 3240
Y2 = 3240
End
Begin VB.Line Line1
BorderColor = &H00FFFFFF&
BorderWidth = 4
Index = 1
X1 = 240
X2 = 4680
Y1 = 3240
Y2 = 3240
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i%

Private Sub Check1_Click()
If Check1.Value = 1 Then
If Option1(0).Value = True Then
Text1.Text = Empty
i = 9
Do Until i < 1
Text1 = Text1 & String(i, "*") & vbCrLf
i = i - 2
Loop
End If

If Option1(1).Value = True Then
Text1.Text = Empty
i = Asc("Z")
Do While i >= Asc("A")
Text1 = Text1 & "Huruf " & Chr(34) & Chr(i) & Chr(34) & vbCrLf
i = i - 1
Loop
End If

If Option1(2).Value = True Then
Text1.Text = Empty
i = 100
Do Until i < 1
Text1 = Text1 & "Angka ke-" & i & vbCrLf
i = i - 1
Loop
End If
Else
If Option1(0).Value = True Then
Option1_Click (0)
End If

If Option1(1).Value = True Then
Option1_Click (1)
End If

If Option1(2).Value = True Then
Option1_Click (2)
End If
End If
End Sub

Private Sub Command1_Click()
Unload Me
End Sub

Private Sub Form_Load()
Option1(0).Value = True
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 Option1_Click(Index As Integer)
Select Case Index
Case 0:
Text1.Text = Empty
Text1.Alignment = 2
Text1.FontSize = 18
For i = 1 To 9 Step 2
Text1 = Text1 & String(i, "*") & vbCrLf
Next
Check1.Value = 0
Case 1:
Text1.Text = Empty
Text1.Alignment = 0
Text1.FontSize = 14
i = Asc("A")
Do Until i > Asc("Z")
Text1 = Text1 & "Huruf " & Chr(34) & Chr(i) & Chr(34) & vbCrLf
i = i + 1
Loop
Check1.Value = 0
Case 2:
Text1.Text = Empty
Text1.Alignment = 0
Text1.FontSize = 14
For i = 1 To 100
Text1 = Text1 & "Angka ke-" & i & vbCrLf
Next
Check1.Value = 0
End Select
End Sub


Unduh Kode Sumber

Label:

0 Komentar:

Posting Komentar

Berlangganan Posting Komentar [Atom]

<< Beranda