Kamis, 14 Februari 2013

KUMPULAN KODE PROGRAM VB6

 pertemuan ke 2
latihan membuat kalkulator

Private Sub Command1_Click()
Dim a, b, c As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a + b
Text3.Text = Str(c)
End Sub

Private Sub Command3_Click()
Dim a, b, c As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a - b
Text3.Text = Str(c)
End Sub

Private Sub Command4_Click()
Dim a, b, c As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a \ b
Text3.Text = Str(c)
End Sub

Private Sub Command5_Click()
Dim a, b, c As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a * b
Text3.Text = Str(c)
End Sub

Private Sub Command6_Click()
Dim a, b, c As Double
a = Val(Text1.Text)
b = Val(Text2.Text)
c = a ^ b
Text3.Text = Str(c)
End Sub

Private Sub Command7_Click()
End
End Sub

Private Sub Command8_Click()

End Sub

pertemuan ke 3 
belajar tentang variabel
Private Sub Label2_Click()

End Sub

Private Sub CmdKeluar_Click()
End
End Sub

Private Sub CmdTambah_Click()
Dim a, b, c As Byte
a = Val(TxtA.Text)
b = Val(TxtB.Text)
c = a + b
TxtC.Text = Str(c)
End Sub
pertemuan ke 4
membuat grafik
Dim r As Single

Private Sub Form_Load()
r = 100
End Sub

Private Sub Form_Paint()
Circle (1500, 1500), 1500
Circle (2500, 3500), 1500
Circle (3500, 1500), 1500
Circle (4500, 3500), 1500
Circle (5500, 1500), 1500
Circle (10000, 1500), 1000
Circle (10000, 3500), 1000
Circle (12000, 1500), 1000
Circle (12000, 3500), 1000
Circle (11000, 2500), 1000
End Sub

Private Sub pct1_paint()
pct1.Line (0, 0)-(3000, 3000)
pct1.Line (-10, 10)-(3000, 3000)
End Sub

Private Sub Timer1_Timer()
pct1.Circle (pct1.ScaleWidth / 2, pct1.ScaleHeight / 2), r
r = r + 50
If r > 1000 Then
r = 100
pct1.Cls
End If
End Sub

Private Sub Timer2_Timer()
pct1.Top = pct1.Top + 50
If pct1.Top > FrmGrafik.Height Then
pct1.Top = -pct1.Height
End If
End Sub

Private Sub Timer3_Timer()
pct1.Left = pct1.Left + 50
If pct1.Left > FrmGrafik.Height Then
pct1.Left = -pct1.Height
End If
End Sub

pertemuan ke 5
belajar membuat print di form
Private Sub Cmddouble_Click()
Form1.Caption = "Jl.Iskandar Muda"
End Sub

Private Sub Form_Load()

End Sub
pertemuan ke 6
membuat game 
Private Sub CmdAtas_Click()
Timer1.Enabled = True
CmdAtas.Enabled = False
CmdKiri.Enabled = True


End Sub

Private Sub CmdBawah_Click()
PctGambar.Top = PctGambar.Top + 30
End Sub

Private Sub CmdKanan_Click()
PctGambar.Left = PctGambar.Left + 30
End Sub

Private Sub CmdKiri_Click()
Timer1.Enabled = False
CmdAtas.Enabled = True
CmdKiri.Enabled = False
Timer2.Enabled = True


End Sub


Private Sub Form_Load()

End Sub

Private Sub Timer1_Timer()
PctGambar.Top = PctGambar.Top - 30
End Sub

Private Sub Timer2_Timer()
PctGambar.Left = PctGambar.Left - 50
End Sub
pertemuan ke 7
membuat penentuan beasiswa


Private Sub Label2_Click()

End Sub

Private Sub Cmdbeasiswa_Click()
Dim ip As Single
ip = Val(TxtIP.Text)
TxtKet.Text = "Tidak Dapat Beasiswa"
If (ip > 3) Then
TxtKet.Text = "Dapat Beasiswa"
End If
End Sub


Private Sub Cmdexit_Click()
End
End Sub

Private Sub TxtIP_Change()
Dim ip As Single
ip = Val(TxtIP.Text)
If (ip > 3) Then
TxtKet.Text = "Dapat Beasiswa"
End If
End Sub


pertemuan ke 8
membuat zodiak
Dim tanggal As Date
Dim tglLhr, blnLhr  As Integer
Dim panggil As String

Private Sub cmdbersih_Click()
Text1.Text = " "
lblZodiak.Caption = " "
End Sub

Private Sub cmdEnter_Click()
    tanggal = Me.DTPicker1.Value
    tglLhr = Day(tanggal)
    blnLhr = Month(tanggal)
   
    If (tglLhr >= 22 And blnLhr = 12) Or (tglLhr <= 20 And blnLhr = 1) Then
        zodiak = "Capricorn"
    ElseIf (tglLhr >= 21 And blnLhr = 1) Or (tglLhr <= 19 And blnLhr = 2) Then
        zodiak = "Aquarius"
    ElseIf (tglLhr >= 20 And blnLhr = 2) Or (tglLhr <= 20 And blnLhr = 3) Then
        zodiak = "Pisces"
    ElseIf (tglLhr >= 21 And blnLhr = 3) Or (tglLhr <= 19 And blnLhr = 4) Then
        zodiak = "Aries"
    ElseIf (tglLhr >= 20 And blnLhr = 4) Or (tglLhr <= 20 And blnLhr = 5) Then
        zodiak = "Taurus"
    ElseIf (tglLhr >= 21 And blnLhr = 5) Or (tglLhr <= 21 And blnLhr = 6) Then
        zodiak = "Gemini"
    ElseIf (tglLhr >= 22 And blnLhr = 6) Or (tglLhr <= 22 And blnLhr = 7) Then
        zodiak = "Cancer"
    ElseIf (tglLhr >= 23 And blnLhr = 7) Or (tglLhr <= 23 And blnLhr = 8) Then
        zodiak = "Leo"
    ElseIf (tglLhr >= 24 And blnLhr = 8) Or (tglLhr <= 22 And blnLhr = 9) Then
        zodiak = "Virgo"
    ElseIf (tglLhr >= 23 And blnLhr = 9) Or (tglLhr <= 23 And blnLhr = 10) Then
        zodiak = "Libra"
    ElseIf (tglLhr >= 24 And blnLhr = 10) Or (tglLhr <= 22 And blnLhr = 11) Then
        zodiak = "Scorpio"
    ElseIf (tglLhr >= 23 And blnLhr = 11) Or (tglLhr <= 21 And blnLhr = 12) Then
        zodiak = "Sagitarius"
    End If
    Me.lblZodiak.Caption = zodiak
   
End Sub

Private Sub Cmdkeluar_Click()
MsgBox ("Yakin anda ingin keluar? Jika anda yakin, tekan OK")
MsgBox (" OK la kalo begitu...")
End
End Sub

Tidak ada komentar:

Posting Komentar