Sabtu, 16 April 2011

Public Class Form1

Dim isitext(4) As String
Dim mListItem As ListViewItem


Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call bersih()
Call setTampilan()
End Sub

Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Tambah" Then
Button1.Text = "Simpan"
Button4.Text = "Batal"
TextBox1.Focus()
Else
isitext(0) = TextBox1.Text
isitext(1) = Trim(TextBox2.Text)
isitext(2) = Trim(TextBox3.Text)
isitext(3) = Microsoft.VisualBasic.Right((ComboBox1.Text), 12)

mListItem = New ListViewItem(isitext)
ListView1.Items.Add(mListItem)
Call bersih()
TextBox1.Focus()

End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "Keluar" Then
Me.Close()
Else
Call bersih()
Call normal()
End If
End Sub
Sub normal()
Button1.Text = "Tambah"
Button1.Enabled = True
Button4.Text = "Keluar"
End Sub

Sub setTampilan()
ListView1.View = View.Details
ListView1.Columns.Add("NPM", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Nama", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Alamat", 100, HorizontalAlignment.Left)
ListView1.Columns.Add("Jurusan", 100, HorizontalAlignment.Left)
End Sub

End Class

Game Puzzel

Temen-temen semua dan setanah air, saya dapat sedikit dari temen deket saya sendiri,walau pun program ini sederhana tapi bisa ngelangin stress juga lho….. ,Ya itu cara membuat game Puzzle dengan Visual studio. Dan ini dibawah ini coding-codingnya.

· Step Pertama : Bukalah program visual basic anda dam PC atau Notebook anda,dan pastikan PC atau Notebook anda sudah terinstal progaram ini.

· Step Kedua : Lalu klik fie, pilih New project. Maka akan tampilan form .

· Step Ketiga : setelah itu buatlah buttom sebayak yang anda suka pada form, yang terdapat pada toolbox

· Step Keempat : Double klik pada setiap buttom,lalu masukan Coding-codingan di bawah ini sesuai urutan buttom dan pastikan coding di bawah sesuai agar tidak terjadi error pada program

· Step KeLima : Setelah itu anda bisa running untuk mencoba program. Bila ok siap dimainkan.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj_WLzjUbG533vziNUzOHPKsbbE6KO6Vb0m9zTGU9Q3PbgLQv8RZcbmqO_XFXwOP5YywWIvuulheR726lyrQFOmfI6rUyBsCM9ZPMqH0h6wbyUGYzXd0cPC7oz-QUHVs5mxZR0lF8N7t2WC/s1600/untitled.bmp

Gambar diatas adalah hasil program yang sudah siap dimainkan.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

If Button2.Visible = False Then

Button2.Visible = True

Button1.Visible = False

Button2.Text = Button1.Text

ElseIf Button4.Visible = False Then

Button4.Visible = True

Button1.Visible = False

Button4.Text = Button1.Text

End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

If Button1.Visible = False Then

Button1.Visible = True

Button2.Visible = False

Button1.Text = Button2.Text

ElseIf Button3.Visible = False Then

Button3.Visible = True

Button2.Visible = False

Button3.Text = Button2.Text

ElseIf Button5.Visible = False Then

Button5.Visible = True

Button2.Visible = False

Button5.Text = Button2.Text

End If

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

If Button2.Visible = False Then

Button2.Visible = True

Button3.Visible = False

Button2.Text = Button3.Text

ElseIf Button6.Visible = False Then

Button6.Visible = True

Button3.Visible = False

Button6.Text = Button3.Text

End If

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

If Button1.Visible = False Then

Button1.Visible = True

Button4.Visible = False

Button1.Text = Button4.Text

ElseIf Button5.Visible = False Then

Button5.Visible = True

Button4.Visible = False

Button5.Text = Button4.Text

ElseIf Button7.Visible = False Then

Button7.Visible = True

Button4.Visible = False

Button7.Text = Button4.Text

End If

End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

If Button3.Visible = False Then

Button3.Visible = True

Button6.Visible = False

Button3.Text = Button6.Text

ElseIf Button5.Visible = False Then

Button5.Visible = True

Button6.Visible = False

Button5.Text = Button6.Text

ElseIf Button9.Visible = False Then

Button9.Visible = True

Button6.Visible = False

Button9.Text = Button6.Text

End If

End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

If Button7.Visible = False Then

Button7.Visible = True

Button8.Visible = False

Button7.Text = Button8.Text

ElseIf Button5.Visible = False Then

Button5.Visible = True

Button8.Visible = False

Button5.Text = Button8.Text

ElseIf Button9.Visible = False Then

Button9.Visible = True

Button8.Visible = False

Button9.Text = Button8.Text

End If

End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

If Button4.Visible = False Then

Button4.Visible = True

Button7.Visible = False

Button4.Text = Button7.Text

ElseIf Button8.Visible = False Then

Button8.Visible = True

Button7.Visible = False

Button8.Text = Button7.Text

End If

End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

If Button6.Visible = False Then

Button6.Visible = True

Button9.Visible = False

Button6.Text = Button9.Text

ElseIf Button8.Visible = False Then

Button8.Visible = True

Button9.Visible = False

Button8.Text = Button9.Text

End If

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

If Button2.Visible = False Then

Button2.Visible = True

Button5.Visible = False

Button2.Text = Button5.Text

ElseIf Button4.Visible = False Then

Button4.Visible = True

Button5.Visible = False

Button4.Text = Button5.Text

ElseIf Button6.Visible = False Then

Button6.Visible = True

Button5.Visible = False

Button6.Text = Button5.Text

ElseIf Button8.Visible = False Then

Button8.Visible = True

Button5.Visible = False

Button8.Text = Button5.Text

End If

End Sub

End Class

Balajar membuat program dengan Listbox, untuk menginput data.

Walau pun dalam mata VB.net ini saya masuk pada saat itu membahas cara pembuatan List Box dengan VB.net. tapi saya tetep ga mau ketinggalan.dan coba bertanya pada teman-teman satu kelas saya akar tidak ketinggalan materi ini. Maklum mahasiswa sambil kerja…..,hahahaahaaha….

Tampilan list box :

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjvfyJTm1fyWew0pMc4qa54QOLAPIcHEtXS5kDt_sQ7r9ElVjSrZMDpf1AaQD0POpobDXyFwh4x9kiewDVajqqqnKPrxdnHuaDR2tlEL932N59obfn8B32d26soPNaHEXExidWDQVXGd86u/s1600/l.bmp


Pembahasan kali ini, kita akan coba membuat program untuk menggabungkan data yang kita input, lalu akan kita gabungkan, dan akan ditampilkan melalui listbox…

Perintah sederhananya :

ListBox1.Items.Add(TextBox.Text +" " + TextBox……..)

Step pertama : buat form seperti tampilan di atas, lalu buat coding seperti dibawah ini :

Sub pros3()
ListBox1.Items.Add(TextBox3.Text + " " + TextBox4.Text + " " + TextBox5.Text + " " _
+ TextBox6.Text + " " + TextBox7.Text)
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox4.Focus()
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
If e.KeyChar = Chr(13) Then
TextBox5.Focus()
End If
End Sub
Private Sub TextBox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
If e.KeyChar = Chr(13) Then
TextBox6.Focus()
End If
End Sub
Private Sub TextBox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
If e.KeyChar = Chr(13) Then
TextBox7.Focus()
End If
End Sub

Private Sub TextBox7_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox7.KeyPress
If e.KeyChar = Chr(13) Then
Call pros3()
Call bersihpros()
TextBox3.Focus()
End If
End Sub
Sub bersihpros()
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
End Sub
End Class

Setelah itu temen-temen bisa jalankan program tsb dengan menekan F5,isi kata untuk data 1 diakhiri dengan Enter, hingga data 7 :