Merhaba arkadaşlar programlama öğrenmek için her zaman yeni örnekler denemelisiniz. Bunun için bugün sizlere Vb.Net ile Sinema Bilet Programı örneğini aktaracağız. Sinema biletlerini nasıl belirleriz? Vb.Net ile Sinema Bilet programı nasıl yapılır? Gibi sorularınızın cevabını bu içerikte bulabilirsiniz.
Kullanılması Gerekenler
Vb.Net ile Sinema Bilet programı örneğinde kullanılması gerekenler sırası ile şunlardır:
20 adet Button, 10 adet Label ve 3 adet TextBox bu program için kullanılması gerekenlerdir.
Kod Alanı
Programımızın kullanım şekli şu şekildedir:
Formumuz açıldığı an bütün butonlarımızın rengini boş koltuk olarak belirlenen yeşil renge dönüştürüyoruz. Bir değişkene 18 adet koltuk bağlamında 18 sayısını koyuyoruz. Bunun sebebi ise seçilen her boş koltuk ile değişkenimizin azaldığını belli etmektir. Adımızı soyadımızı girip boş olan koltuğu seçiyoruz ve sonradan perde diyoruz. Perde dediğimiz anda labeller deki koltuk sayıları ve seçtiğimiz butonun rengi değişiyor. Eğer rezervasyon iptal etmek istersek adımızı ve soyadımızı yazıyor ve rezervasyon iptali butonuna basıyoruz. Tekrardan seçtiğimiz koltuk yeşile ve koltuk sayıları ile ilgili labeller deki sayılarımız da değişiyor.
Bu program bir çok butonu aynı anda kullanmayı öğrenmek için önemlidir. Bu tip programları iyi kavramak demek daha uzun soluklu kodlamalar da yapılması gereken detaylara daha çabuk hakim olmak demektir. Sizler de kendi sinema bilet programınızı yapıp bizlerle paylaşabilirsiniz. Biz de severek sizin adınıza paylaşırız. İyi çalışmalar
Public Class Form1
Dim i, x As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.button1.BackColor = System.Drawing.Color.Green
Me.button2.BackColor = System.Drawing.Color.Green
Me.button3.BackColor = System.Drawing.Color.Green
Me.button4.BackColor = System.Drawing.Color.Green
Me.button5.BackColor = System.Drawing.Color.Green
Me.button6.BackColor = System.Drawing.Color.Green
Me.button7.BackColor = System.Drawing.Color.Green
Me.button8.BackColor = System.Drawing.Color.Green
Me.button9.BackColor = System.Drawing.Color.Green
Me.button10.BackColor = System.Drawing.Color.Green
Me.button11.BackColor = System.Drawing.Color.Green
Me.button12.BackColor = System.Drawing.Color.Green
Me.button13.BackColor = System.Drawing.Color.Green
Me.button14.BackColor = System.Drawing.Color.Green
Me.button15.BackColor = System.Drawing.Color.Green
Me.button16.BackColor = System.Drawing.Color.Green
Me.button17.BackColor = System.Drawing.Color.Green
Me.button18.BackColor = System.Drawing.Color.Green
x = 18
End Sub
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button1.Text = textBox1.Text + " " + textBox2.Text
Me.button1.BackColor = System.Drawing.Color.Red
button1.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button2.Text = textBox1.Text + " " + textBox2.Text
Me.button2.BackColor = System.Drawing.Color.Red
button2.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button3.Text = textBox1.Text + " " + textBox2.Text
Me.button3.BackColor = System.Drawing.Color.Red
button3.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button4.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button4.Text = textBox1.Text + " " + textBox2.Text
Me.button4.BackColor = System.Drawing.Color.Red
button4.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button5.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button5.Text = textBox1.Text + " " + textBox2.Text
Me.button5.BackColor = System.Drawing.Color.Red
button5.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button7.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button7.Text = textBox1.Text + " " + textBox2.Text
Me.button7.BackColor = System.Drawing.Color.Red
button7.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button8.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button8.Text = textBox1.Text + " " + textBox2.Text
Me.button8.BackColor = System.Drawing.Color.Red
button8.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button9.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button9.Text = textBox1.Text + " " + textBox2.Text
Me.button9.BackColor = System.Drawing.Color.Red
button9.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button10.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button10.Text = textBox1.Text + " " + textBox2.Text
Me.button10.BackColor = System.Drawing.Color.Red
button10.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button12.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button12.Text = textBox1.Text + " " + textBox2.Text
Me.button12.BackColor = System.Drawing.Color.Red
button12.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button13.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button13.Text = textBox1.Text + " " + textBox2.Text
Me.button13.BackColor = System.Drawing.Color.Red
button13.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button14.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button14.Text = textBox1.Text + " " + textBox2.Text
Me.button14.BackColor = System.Drawing.Color.Red
button14.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button15.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button15.Text = textBox1.Text + " " + textBox2.Text
Me.button15.BackColor = System.Drawing.Color.Red
button15.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button17_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button17.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button17.Text = textBox1.Text + " " + textBox2.Text
Me.button17.BackColor = System.Drawing.Color.Red
button17.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button6.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button6.Text = textBox1.Text + " " + textBox2.Text
Me.button6.BackColor = System.Drawing.Color.Red
button6.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button11.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button11.Text = textBox1.Text + " " + textBox2.Text
Me.button11.BackColor = System.Drawing.Color.Red
button11.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button16.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button16.Text = textBox1.Text + " " + textBox2.Text
Me.button16.BackColor = System.Drawing.Color.Red
button16.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button18.Click
If (textBox1.Text <> "" And textBox2.Text <> "") Then
button18.Text = textBox1.Text + " " + textBox2.Text
Me.button18.BackColor = System.Drawing.Color.Red
button18.Enabled = False
textBox1.Text = ""
textBox2.Text = ""
i = i + 1
x = x - 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
Else
MessageBox.Show("isim yada soyadınız tam değil")
End If
End Sub
Private Sub button20_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button20.Click
If (textBox3.Text.ToLower() = button1.Text.ToLower()) Then
button1.Text = ""
Me.button1.BackColor = System.Drawing.Color.Green
button1.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button2.Text.ToLower()) Then
button2.Text = ""
Me.button2.BackColor = System.Drawing.Color.Green
button2.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button3.Text.ToLower()) Then
button3.Text = ""
Me.button3.BackColor = System.Drawing.Color.Green
button3.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button4.Text.ToLower()) Then
button4.Text = ""
Me.button4.BackColor = System.Drawing.Color.Green
button4.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button5.Text.ToLower()) Then
button5.Text = ""
Me.button5.BackColor = System.Drawing.Color.Green
button5.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button6.Text.ToLower()) Then
button6.Text = ""
Me.button6.BackColor = System.Drawing.Color.Green
button6.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button7.Text.ToLower()) Then
button7.Text = ""
Me.button7.BackColor = System.Drawing.Color.Green
button7.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button8.Text.ToLower()) Then
button8.Text = ""
Me.button8.BackColor = System.Drawing.Color.Green
button8.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button9.Text.ToLower()) Then
button9.Text = ""
Me.button9.BackColor = System.Drawing.Color.Green
button9.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button10.Text.ToLower()) Then
button10.Text = ""
Me.button10.BackColor = System.Drawing.Color.Green
button10.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button11.Text.ToLower()) Then
button11.Text = ""
Me.button11.BackColor = System.Drawing.Color.Green
button11.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button12.Text.ToLower()) Then
button12.Text = ""
Me.button12.BackColor = System.Drawing.Color.Green
button12.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button13.Text.ToLower()) Then
button13.Text = ""
Me.button13.BackColor = System.Drawing.Color.Green
button13.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button14.Text.ToLower()) Then
button14.Text = ""
Me.button14.BackColor = System.Drawing.Color.Green
button14.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button15.Text.ToLower()) Then
button15.Text = ""
Me.button15.BackColor = System.Drawing.Color.Green
button15.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button16.Text.ToLower()) Then
button16.Text = ""
Me.button16.BackColor = System.Drawing.Color.Green
button16.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button17.Text.ToLower()) Then
button17.Text = ""
Me.button17.BackColor = System.Drawing.Color.Green
button17.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
If (textBox3.Text.ToLower() = button18.Text.ToLower()) Then
button18.Text = ""
Me.button18.BackColor = System.Drawing.Color.Green
button18.Enabled = True
i = i - 1
x = x + 1
label3.Text = "Dolu: " & i
label4.Text = "Boş: " & x
End If
End Sub
End Class
