Ni coyyyyyyy.........

Public Class Form1
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
For i As Integer = Val(TextBox1.Text) To Val(TextBox2.Text)

If i Mod 7 = 0 Then
ListBox1.Items.Add(i)
i = i * 3
i = i - 4

End If
Next
End Sub
End Class


Menampilkan Data pada List view

Buat dulu design keya gini :


truzz di koding begini yakkk :

Public Class Form1
Dim isitext(4) As String
Dim item As ListViewItem


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

Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = " 06 Teknik Informatika "
End Sub
Sub isikombo()
ComboBox1.Items.Add(" 06 Teknik Informatika ")
ComboBox1.Items.Add(" 07 Sistem Informasi ")
ComboBox1.Items.Add(" 67 Komputer Akuntansi ")
ComboBox1.Items.Add(" 05 Teknik Komputer ")
ComboBox1.Items.Add(" 26 Management Informatika ")
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"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "batal"
TextBox1.Focus()
Else
isitext(0) = Trim(TextBox1.Text)
isitext(1) = Trim(TextBox2.Text)
isitext(2) = Trim(TextBox3.Text)
isitext(3) = Microsoft.VisualBasic.Left(Trim(ComboBox1.Text), 2)

item = New ListViewItem(isitext)
ListView1.Items.Add(item)

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

Button2.Text = "ubah"
Button2.Enabled = True

Button3.Text = "hapus"
Button3.Enabled = True

Button4.Text = "keluar"

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Button2.Text = "ubah" Then
Button2.Text = "simpan"
Button1.Enabled = False
Button3.Enabled = False
Button4.Text = "batal"
TextBox1.Focus()
Else

End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If Button3.Text = "hapus" Then
Button3.Text = "simpan"
Button1.Enabled = False
Button2.Enabled = False
Button4.Text = "batal"
TextBox1.Focus()
Else

End If
End Sub
Sub tampilan()
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.Center)
End Sub

Private Sub ListView1_ItemSelectionChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.ListViewItemSelectionChangedEventArgs) Handles ListView1.ItemSelectionChanged
TextBox1.Text = e.Item.Text
End Sub
End Class



Begitu Bunyinya Gannn!!! OKK.... Met UJian Yaaaa.. ^_*


Tugas VB, Buat Puzzle

Tugas kali ini yang diberikan dosen kepada kami untuk membuat sebuah puzzle, makin lama makin susah aja tugas. Ampun2, tapi kita akan coba semaksimal mungkin mari kita mulai,Awalnya sebuah puzzle yang akan kita buat terdiri dari 9 buah button.

Seperti pada gambar di bawah ini :












Setelah kita buat 9 buah button, mari kita masukan sintak2'a, Kita mulai dari button1 dimana kita rubah propertis visible'a menjadi " False" seperti gambar di bawah ini boz...!!






Wah gambar'a ga jelas, ni w kasih sintak asli'a...
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
Else
If Button4.Visible = False Then
Button4.Visible = True
Button1.Visible = False
Button4.Text = Button1.Text
End If
End If
cek()
End Sub

setelah itu kita lanjutkan ke button2 sampai button 9, sintak'a seperti ini...

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
cek()
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
Else
If Button6.Visible = False Then
Button6.Visible = True
Button3.Visible = False
Button6.Text = Button3.Text
End If
End If
cek()
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
cek()
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 Button9.Visible = False Then
Button9.Visible = True
Button6.Visible = False
Button9.Text = Button6.Text
ElseIf Button5.Visible = False Then
Button5.Visible = True
Button6.Visible = False
Button5.Text = Button6.Text
End If
cek()
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 Button9.Visible = False Then
Button9.Visible = True
Button8.Visible = False
Button9.Text = Button8.Text
ElseIf Button5.Visible = False Then
Button5.Visible = True
Button8.Visible = False
Button5.Text = Button8.Text
End If
cek()
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If Button8.Visible = False Then
Button8.Visible = True
Button7.Visible = False
Button8.Text = Button7.Text
Else
If Button4.Visible = False Then
Button4.Visible = True
Button7.Visible = False
Button4.Text = Button7.Text
End If
End If
cek()
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
Else
If Button8.Visible = False Then
Button8.Visible = True
Button9.Visible = False
Button8.Text = Button9.Text
End If
End If
cek()
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
cek()
End Sub

Private Sub cek()
If (Button1.Text = "1" And Button2.Text = "2" And Button3.Text = "3" And Button4.Text = "4") Then
If (Button5.Text = "5" And Button6.Text = "6" And Button7.Text = "7") Then
If (Button8.Text = "8") Then
MessageBox.Show("Selesai")
End If
End If
End If
End Sub

End Class

Setelah kita selesai memasukan semua perintah, kita coba running atau tekan tombol F5
Jika berhasil maka akan tampil gambar seperti di bawah ini...













Cukup sulit tapi menantang kan, Selamat mencoba,,,
jangan lupa komentar'a yang baik2 ja....??? hehe, Wassalam


Looping pada VB.Net 2008, soal 2

Looping kali ini hampir mirip kaya looping pada soal No.1, hanya saja bilangan yang akan kita masukan penbaginya 4 sisa hasilnya adalah 3, mari kita mulai....


Awalnya kita membuat form yang terdiri 1botton untuk proses, 1 textb
ox untuk input nilai dan 1 listbox untuk
menampilkan hasilnya.


Setelah selesai membuat form seperti gambaran diatas langkah se

lanjutnya membuat coding, begini caranya …?











Public Class Form1

Private Sub Proses_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Proses.Click
Dim i As Integer
ListBox1.Items.Clear()

For i = 1 To Val(TextBox1.Text)

If (i Mod 4 = 3) Then

ListBox1.Items.Add(i)
End If

Next
End Sub
End Class

Disini kita akan menampilkan hasil 0 jika pembaginya 4 dan sisa hasilnya 3 dari bilangan 1 sampai 100, maka…..

masukan coding sesuai pada tampilan diatas tanpa merubah sedikit kata apapun.

Kecuali mau menampilkan dengan hasil yang beda.

Setelah semua tertulis dengan benar, maka mari kita Running.

Jika g’ ada yang ERROR maka hasil tampilannya akan seperti berikut ini :








Hampir sama kan seperti soal No.1, hanya saja hasil bagi'a yang berbeda...Selamat mencoba


Daftar Blog Saya

About Me

Diberdayakan oleh Blogger.

About


ShoutMix chat widget