Selamat Pagi Sobat Miev Kali Ini Miev akan Sharing Untuk Pembelajaran Bahasa Pemrograman terutama untuk yang masih dasar dan ingin mencoba belajar,di sinih ada koding untuk Pembelajaran Visual Basic, Sobat Miev Bisa Klik linknya dan lihat koding apa saja yang ada,ambil yang mungkin sobat Miev bermanfaat.
Latihan :
1 .User Interface modifikasi kode program
Begin VB.Form
Form1
Caption =
"Property Test"
ClientHeight =
3060
ClientLeft =
90
ClientTop =
450
ClientWidth =
4620
LinkTopic =
"Form1"
ScaleHeight =
10980
ScaleWidth =
20310
StartUpPosition = 2
'CenterScreen
Begin VB.Frame Frame1
Caption =
"Pilihan :"
Height =
4455
Left =
9480
TabIndex =
5
Top =
360
Width =
3135
Begin VB.OptionButton Option5
Caption =
"merah"
Height =
255
Left =
240
TabIndex =
13
Top =
2400
Width =
1575
End
Begin VB.OptionButton Option4
Caption =
"ungu"
Height =
255
Left =
240
TabIndex =
12
Top =
1920
Width =
1935
End
Begin VB.OptionButton Option3
Caption =
"kuning"
Height =
375
Left =
240
TabIndex =
11
Top =
1440
Width
= 1695
End
Begin VB.CheckBox Check3
Caption =
"garis bawah"
Height =
375
Left =
240
TabIndex =
10
Top =
3720
Width =
1815
End
Begin VB.CheckBox Check2
Caption =
"Miring"
Height =
375
Left =
240
TabIndex =
9
Top =
3240
Width
= 1935
End
Begin VB.CheckBox Check1
Caption =
"Tebal"
Height =
375
Left =
240
TabIndex =
8
Top =
2760
Width =
1695
End
Begin VB.OptionButton Option2
Caption =
"hijau"
Height =
375
Left =
240
TabIndex =
7
Top =
960
Width =
1695
End
Begin VB.OptionButton Option1
Caption =
"Biru"
Height =
375
Left =
240
TabIndex =
6
Top =
480
Width =
1695
End
End
Begin VB.CommandButton Command2
Caption =
"Selesai"
Height =
495
Left =
5160
TabIndex =
4
Top =
2880
Width
= 2295
End
Begin VB.CommandButton Command1
Caption =
"OK"
Height =
495
Left =
1440
TabIndex =
3
Top =
2880
Width =
2415
End
Begin VB.TextBox Text1
Height =
615
Left =
3960
TabIndex =
1
Top =
240
Width =
4815
End
Begin VB.Label Label2
Alignment =
2 'Center
Caption =
"Label2"
BeginProperty Font
Name =
"MS Sans Serif"
Size =
24
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
0 'False
Strikethrough =
0 'False
EndProperty
Height =
615
Left =
480
TabIndex =
2
Top =
1320
Width =
8175
End
Begin VB.Label Label1
Caption =
"tuliskan nama anda"
Height =
495
Left =
600
TabIndex =
0
Top =
360
Width =
2775
End
End
Attribute VB_Name
= "Form1"
Attribute
VB_GlobalNameSpace = False
Attribute
VB_Creatable = False
Attribute
VB_PredeclaredId = True
Attribute
VB_Exposed = False
Private Sub
Check3_Click()
Label2.FontUnderline
= Check3.Value
End Sub
Private Sub
Command1_Click()
Label2.Caption =
Text1.Text
End Sub
Private Sub
Command2_Click()
End
End Sub
Private Sub
Option1_Click()
Label2.ForeColor
= vbBlue
End Sub
Private Sub
Option2_Click()
Label2.ForeColor
= vbGreen
End Sub
Private Sub
Check1_Click()
Label2.FontBold =
Check1.Value
End Sub
Private Sub
Check2_Click()
Label2.FontItalic
= Check2.Value
End Sub
Private Sub
Option3_Click()
Label2.ForeColor
= vbYellow
End Sub
Private Sub
Option4_Click()
Label2.ForeColor
= vbviolet
End Sub
Private Sub Option5_Click()
Label2.ForeColor
= vbRed
End Sub
2. penggunaan data variabel 4
Begin VB.Form
Form3
ClientHeight =
3060
ClientLeft =
90
ClientTop =
450
ClientWidth =
4620
LinkTopic =
"Form1"
ScaleHeight =
3060
ScaleWidth =
4620
StartUpPosition = 2
'CenterScreen
Begin VB.CommandButton Command3
Caption =
"Test 3"
Height =
615
Left =
480
TabIndex =
2
Top =
2880
Width =
2295
End
Begin VB.CommandButton Command2
Caption =
"Test 2"
Height =
615
Left =
480
TabIndex =
1
Top =
1800
Width =
2295
End
Begin VB.CommandButton Command1
Caption =
"Test 1"
Height =
615
Left =
480
TabIndex =
0
Top =
600
Width =
2295
End
Begin VB.Label Label3
BackColor =
&H00E0E0E0&
Height =
495
Left =
3720
TabIndex =
5
Top =
2880
Width =
5415
End
Begin VB.Label Label2
BackColor =
&H00E0E0E0&
Height =
615
Left =
3720
TabIndex =
4
Top =
1800
Width =
5415
End
Begin VB.Label Label1
BackColor =
&H00E0E0E0&
Height =
615
Left =
3720
TabIndex =
3
Top =
600
Width =
5415
End
End
Attribute VB_Name
= "Form3"
Attribute
VB_GlobalNameSpace = False
Attribute
VB_Creatable = False
Attribute VB_PredeclaredId
= True
Attribute
VB_Exposed = False
Dim test2 As
Integer
Private Sub
Command1_Click()
Dim test1 As
String
test1 =
"nusantara"
Label1.Caption =
test1
Label2.Caption =
test2
Label3.Caption =
test3
End Sub
Private Sub
Command2_Click()
test2 = 10
Label1.Caption =
test1
Label2.Caption =
test2
Label3.Caption =
test3
End Sub
Private Sub
Command3_Click()
Const test3 As
Single = 90.55
Label1.Caption =
test1
Label2.Caption =
test2
Label3.Caption =
test3
End Sub
3. membuat kalkulator
Begin VB.Form
Form1
BorderStyle =
1 'Fixed Single
Caption =
"kalkulator"
ClientHeight =
5520
ClientLeft =
90
ClientTop =
450
ClientWidth =
6930
BeginProperty Font
Name
= "Snap ITC"
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 =
5520
ScaleWidth =
6930
StartUpPosition = 1
'CenterOwner
Begin VB.CommandButton cmdhitung
Caption =
"="
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Left =
4080
TabIndex =
17
Top =
3600
Width =
1935
End
Begin VB.CommandButton cmdoperator
Caption =
"/"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
3
Left =
5160
TabIndex =
16
Top =
2880
Width =
855
End
Begin VB.CommandButton cmdoperator
Caption =
"*"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
2
Left =
4080
TabIndex =
15
Top =
2880
Width =
855
End
Begin VB.CommandButton cmdoperator
Caption =
"-"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
615
Index = 1
Left =
5160
TabIndex =
14
Top =
2040
Width =
855
End
Begin VB.CommandButton cmdoperator
Caption =
"+"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough = 0 'False
EndProperty
Height =
615
Index =
0
Left =
4080
TabIndex =
13
Top =
2040
Width =
855
End
Begin VB.CommandButton cmdhapus
Caption =
"C"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Left =
5160
TabIndex =
12
Top =
1440
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"7"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
10
Left =
600
TabIndex =
11
Top
= 2880
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"8"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
9
Left =
1800
TabIndex =
10
Top =
2880
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"9"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
8
Left =
3000
TabIndex =
9
Top =
2880
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"0"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
7
Left =
600
TabIndex =
8
Top =
3600
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"."
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
6
Left =
1800
TabIndex =
7
Top =
3600
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"6"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
5
Left =
3000
TabIndex =
6
Top =
2160
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"5"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index
= 4
Left =
1800
TabIndex =
5
Top =
2160
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"4"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
3
Left =
600
TabIndex =
4
Top =
2160
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"3"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
2
Left =
3000
TabIndex =
3
Top =
1440
Width =
855
End
Begin VB.CommandButton cmdangka
Caption =
"2"
BeginProperty Font
Name =
"Snap ITC"
Size =
9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
1
Left =
1800
TabIndex =
2
Top =
1440
Width =
855
End
Begin VB.CommandButton cmdangka
BackColor =
&H80000008&
Caption =
"1"
BeginProperty Font
Name =
"Snap ITC"
Size
= 9.75
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
-1 'True
Strikethrough =
0 'False
EndProperty
Height =
495
Index =
0
Left =
600
MaskColor =
&H00FFFFFF&
TabIndex =
1
Top =
1440
Width =
855
End
Begin VB.TextBox Text1
Alignment =
1 'Right Justify
BackColor =
&H0000FFFF&
BeginProperty Font
Name =
"MS Sans Serif"
Size =
8.25
Charset =
0
Weight =
400
Underline =
0 'False
Italic =
0 'False
Strikethrough =
0 'False
EndProperty
Height =
615
Left =
600
TabIndex =
0
Top =
240
Width =
5535
End
End
Attribute VB_Name
= "Form1"
Attribute
VB_GlobalNameSpace = False
Attribute
VB_Creatable = False
Attribute
VB_PredeclaredId = True
Attribute
VB_Exposed = False
Dim angka(1 To 2)
As Single
Dim Operator As
String
Private Sub
cmdangka_Click(Index As Integer)
Text1.Text =
Text1.Text & cmdangka(Index).Caption
End Sub
Private Sub
cmdhapus_Click()
Text1.Text =
""
End Sub
Private Sub
cmdhitung_Click()
Dim hasil As
Single
If Text1.Text =
"" Then Exit Sub
angka(2) =
CSng(Text1.Text)
Select Case
Operator
Case
"+"
hasil = angka(1)
+ angka(2)
Case
"-"
hasil = angka(1)
- angka(2)
Case
"*"
hasil = angka(1)
* angka(2)
Case
"/"
hasil = angka(1)
/ angka(2)
End Select
Text1.Text =
hasil
End Sub
Private Sub
cmdoperator_Click(Index As Integer)
If Text1.Text =
"" Then Exit Sub
angka(1) =
CSng(Text1.Text)
Operator =
cmdoperator(Index).Caption
Text1.Text =
""
End Sub
dan bisa di download latihan latihan yang lainnya dari 19 coding untuk latihan. di bawah ini.
Download Tutorial Visual Basic (C++)
Download Tutorial Visual Basic (C++)
Password : softmiev.
0 komentar:
Posting Komentar