Minggu, 04 Agustus 2013

KONVERSI JAM MENGGUNAKAN VISUAL BASIC


Hey guys. Penasaran bagaimana caranya bikin program visual basic untuk melihat sudut terbesar dan sudut terkecil dari jarum jam yang ditunjukan. Lets check it out.

Pertama-tama buat tampilan seperti contoh ddibawah ini
yang digunakan hanya label , textbox dan commandbutton. Tidak ada perubahan pada propertiesnya.

Kemudian, dilanjut dengan kodingnya



Private Sub Command1_Click()
Dim J As Integer
J = Val(Text1)
Dim M As Integer
M = Val(Text2)
Dim A As Integer
A = (30 * J) + (1 / 2 * M)
Dim B As Integer
B = 6 * M

If A > B Then
Text3.Text = A - B
Text4.Text = 360 - Val(Text3)
Else
Text3.Text = B - A
Text4.Text = 360 - Val(Text3)

If Val(Text3) > Val(Text4) Then
If A > B Then
Text4.Text = A - B
Text3.Text = 360 - Val(Text4)
Else
Text4.Text = B - A
Text3.Text = 360 - Val(Text4)
End If
End If
End If
End Sub

Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
Text3.Text = " "
Text4.Text = " "
End Sub

Private Sub Command3_Click()
End
End Sub

selamat mencoba :)

Sabtu, 03 Agustus 2013

MEMBUAT UNDIAN ANGKA HURUF DENGAN VISUAL BASIC

Mau tau caranya bikin program undian angka huruf menggunakan visual basic seperti dibawah ini :
untuk kodingannya :




Private Sub Command1_Click()
Timer1.Enabled = True
Label1.Caption = ""
Label2.Caption = ""
Label3.Caption = ""
Label4.Caption = ""
End Sub

Private Sub Command2_Click()
Timer1.Enabled = False
Label5.Caption = Label1.Caption & Label2.Caption & Label3.Caption & Label4.Caption & Label6.Caption & Label7.Caption & Label8.Caption & Label9.Caption
End Sub

Private Sub Command3_Click()
End
End Sub

Private Sub Label2_Change()
Dim huruf As Variant
huruf = Label2.Caption
Select Case huruf
Case 0
Cls
Label2.Caption = " A "
Case 1
Cls
Label2.Caption = " B "
Case 2
Cls
Label2.Caption = " C "
Case 3
Cls
Label2.Caption = " D "
Case 4
Cls
Label2.Caption = " E "
Case 5
Cls
Label2.Caption = " F "
Case 6
Cls
Label2.Caption = " G "
Case 7
Cls
Label2.Caption = " H "
Case 8
Cls
Label2.Caption = " I "
Case 9
Cls
Label2.Caption = " J "
End Select
End Sub

Private Sub Label4_Change()
Dim huruf As Variant
huruf = Label4.Caption
Select Case huruf
Case 0
Cls
Label4.Caption = " A "
Case 1
Cls
Label4.Caption = " B "
Case 2
Cls
Label4.Caption = " C "
Case 3
Cls
Label4.Caption = " D "
Case 4
Cls
Label4.Caption = " E "
Case 5
Cls
Label4.Caption = " F "
Case 6
Cls
Label4.Caption = " G "
Case 7
Cls
Label4.Caption = " H "
Case 8
Cls
Label4.Caption = " I "
Case 9
Cls
Label4.Caption = " J "
End Select
End Sub


Private Sub Label7_Change()
Dim huruf As Variant
huruf = Label7.Caption
Select Case huruf
Case 0
Cls
Label7.Caption = " A "
Case 1
Cls
Label7.Caption = " B "
Case 2
Cls
Label7.Caption = " C "
Case 3
Cls
Label7.Caption = " D "
Case 4
Cls
Label7.Caption = " E "
Case 5
Cls
Label7.Caption = " F "
Case 6
Cls
Label7.Caption = " G "
Case 7
Cls
Label7.Caption = " H "
Case 8
Cls
Label7.Caption = " I "
Case 9
Cls
Label7.Caption = " J "
End Select
End Sub

Private Sub Label9_Change()
Dim huruf As Variant
huruf = Label9.Caption
Select Case huruf
Case 0
Cls
Label9.Caption = " A "
Case 1
Cls
Label9.Caption = " B "
Case 2
Cls
Label9.Caption = " C "
Case 3
Cls
Label9.Caption = " D "
Case 4
Cls
Label9.Caption = " E "
Case 5
Cls
Label9.Caption = " F "
Case 6
Cls
Label9.Caption = " G "
Case 7
Cls
Label9.Caption = " H "
Case 8
Cls
Label9.Caption = " I "
Case 9
Cls
Label9.Caption = " J "
End Select
End Sub


Private Sub Timer1_Timer()
Label1.Caption = Int(Rnd * 10)
Label2.Caption = Int(Rnd * 10)
Label3.Caption = Int(Rnd * 10)
Label4.Caption = Int(Rnd * 10)
Label6.Caption = Int(Rnd * 10)
Label7.Caption = Int(Rnd * 10)
Label8.Caption = Int(Rnd * 10)
Label9.Caption = Int(Rnd * 10)
End Sub

silahkan dicoba. semoga bemanfaat ya :)

MEMBUAT PIRAMIDA BINTANG DENGAN VISUAL BASIC


Piramida berbintang itu gampang kok buatnya. namun, ada beberapa hal yang perlu diperhatikan
yaitu :

untuk membuat seperti listnya itu, sebenarnya menggunakan textbox tapi dibagian properties pada alignmentnya dirubah menjai center. kemudian pada bagian multiline nya dirubah menjadi True.

berikut kodingnya :



Private Sub Command1_Click()
Dim i As Integer
n = Val(Text2.Text)
For i = 1 To n
Text1.Text = Text1 & String(i, "*") & vbCrLf
Next
End Sub

Private Sub Command2_Click()
Text1.Text = " "
Text2.Text = " "
End Sub

Private Sub Command3_Click()
End
End Sub

semoga bermanfaat ya :)

MEMBUAT KALKULATOR MENGGUNAKAN VISUAL BASIC

hay guys, mau share cara bikin program kalkulator dengan visual basic. Ini sih cuma tutorial sederhana, semoga bermanfaat ya buat kalian yang lagi bingung mau bikinnya.

check it out !!!

awalnya, buat seperti contoh diatas.
buat frame dahulu, kemudian textbox untuk menampilkan hasilnya. Untuk tombol kalkulatornya semuanya menggunakan command button. Tapi, ada yang perlu diperhatikan :
untuk commandbutton 0 - 9 dan . pada name di propertiesnya dirubah menjadi angka.
untuk commandbutton +/- pada name propertiesnya dirubah menjadi plusmin
untuk commandbutton + pada name propertiesnya dirubah menjadi tambah
untuk commandbutton - pada name propertiesnya dirubah menjadi kurang
untuk commandbutton 1/*  pada name propertiesnya dirubah menjadi tanda
untuk commandbutton * pada name propertiesnya dirubah menjadi kali
untuk commandbutton /  pada name propertiesnya dirubah menjadi bagi
untuk commandbutton = pada name propertiesnya dirubah menjadi samadengan
untuk commandbutton lainnya pada properties dibagian name nya tidak perlu diganti.

Berikut kodingannya



Option Explicit
Dim operasi1 As Double, operasi2 As Double
Dim operator As String
Dim hapustampilan As Boolean

Private Sub angka_Click(Index As Integer)
If hapustampilan Then
hasil.Text = " "
hapustampilan = False
End If
hasil.Text = hasil.Text + angka(Index).Caption
End Sub

Private Sub bagi_Click()
operasi1 = Val(hasil.Text)
operator = "/"
hasil.Text = " "
End Sub

Private Sub Command12_Click()
operasi1 = Val(hasil.Text)
operator = "sin"
hasil.Text = " "
End Sub

Private Sub Command15_Click()
End
End Sub

Private Sub Command16_Click()
hasil = " "
End Sub

Private Sub Command22_Click()
operasi1 = Val(hasil.Text)
operator = "^"
hasil.Text = " "
End Sub

Private Sub kali_Click()
operasi1 = Val(hasil.Text)
operator = "*"
hasil.Text = " "
End Sub

Private Sub kurang_Click()
operasi1 = Val(hasil.Text)
operator = "-"
hasil.Text = " "
End Sub

Private Sub plusmin_Click()
hasil.Text = -(Val(hasil.Text))
End Sub

Private Sub samadengan_Click()
Dim hasilakhir As Double
operasi2 = Val(hasil.Text)
If operator = "+" Then hasilakhir = operasi1 + operasi2
If operator = "-" Then hasilakhir = operasi1 - operasi2
If operator = "*" Then hasilakhir = operasi1 * operasi2
If operator = "^" Then hasilakhir = operasi1 ^ operasi2
If operator = "/" And operasi2 <> "0" Then hasilakhir = operasi1 / operasi2
If operator = "1/*" And operasi1 <> "0" Then hasilakhir = 1 / operasi1
hasil.Text = hasilakhir
End Sub

Private Sub tambah_Click()
operasi1 = Val(hasil.Text)
operator = "+"
hasil.Text = " "
End Sub

Private Sub tanda_Click()
operasi1 = Val(hasil.Text)
operator = "1/*"
hasil.Text = " "
End Sub


sekian tutorialnya guys. semoga bermanfaat ya :)

BARIS BILANGAN


Hey guys, ini materi visual basic tentang membuat n baris bilangan.
yang dipakai itu 1 label , 2 textbox dan 1 commandbutton..

gampang kok buatnya. :)

kodingannya


Private Sub Command1_Click()
N = Val(Text1)
For baris = 1 To N
If baris Mod 2 = 0 Then
awal = 5: akhir = 1
langkah = -1
Else
awal = 1: akhir = 5a
langkah = 1
End If
kal = ""
For i = awal To akhir Step langkah
kal = kal & Str(i)
Next i
List1.AddItem kal
Next baris
End Sub

semoga, bermanfaat ya postingannya ini :)