Onur Ateş Kişisel Web Sayfası
  VB.Net
 

 

Bu örneğimiz için gerekli olan toolbox nesneleri : 2 adet button’dur

 

 

 

Public Class Form1

   

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

        Try

            Dim notu As Byte

            notu = InputBox("notunuzu girin")

            If notu <= 100 Then

                If notu <= 44 Then

                    MsgBox("kaldınız")

                ElseIf notu > 44 Then

                    MsgBox("geçtiniz")

                End If

            Else

                MsgBox("not 100'den küçük olmalı")

            End If

        Catch ex As Exception

            MsgBox("yanlış değer girdiniz")

        End Try

    End Sub

 

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

        Dim notu As Byte

        Try

            notu = InputBox("Notunuzu Giriniz")

            If notu >= 0 And notu < 25 Then

                MsgBox("0-kaldınız")

            ElseIf notu >= 25 And notu < 45 Then

                MsgBox("1-Kaldınız")

            ElseIf notu >= 45 And notu < 55 Then

                MsgBox("2-Geçtiniz")

            ElseIf notu >= 55 And notu < 70 Then

                MsgBox("3-Geçtiniz")

            ElseIf notu >= 70 And notu < 85 Then

                MsgBox("4-Geçtiniz")

            ElseIf notu >= 85 And notu < 100 Then

                MsgBox("5-Geçtiniz")

            End If

        Catch ex As Exception

            MsgBox("yanlış değer girdiniz")

        End Try

    End Sub

End Class

 

AÇIKLAMA : Programımızda hem 5’lik hem de 100’lük not sistemi kullanılmıştır. Siz aldığınız notu yazı kutusuna yazdığınız zaman sınıfı geçip geçmediğinizi belirtir.

 

 

 

Program için gerekli toolbox nesneleri : 3 adet button, 1 adet timer, 1 adet label ve 1 adet textbox’tır.

 

Public Class Form1

    Dim oran, kalan As Integer

 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        If kalan = 0 Then

            Timer1.Stop()

            MsgBox("İŞLeM BiTTi")

        End If

        Dim aralık As Integer

        aralık = ProgressBar1.Maximum - ProgressBar1.Minimum

        ' kalan dim işleminin yüzdesi hesaplanır

        Dim oran As Integer = (aralık - kalan) / aralık * 100

        Label1.Text = oran & "% tamamlandı"

        ProgressBar1.Value = ProgressBar1.Maximum - kalan

        kalan -= 1

        If Timer1.Enabled = False Then

            Timer1.Enabled = True

        End If

 

 

    End Sub

 

    Private Sub btnbaslat_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbaslat.Click

        kalan = ProgressBar1.Maximum

        Timer1.Start()

        Button2.Text = "duraklat"

    End Sub

 

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

        Timer1.Enabled = False

        Button1.Text = "devam ettir"

    End Sub

 

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

        Timer1.Enabled = True

 

    End Sub

End Class

 

 

 

 

AÇIKLAMA : Programımızda ilk button label’de yüzde (%) sayımı yaparak progressbar’ı harekete geçirmektedir.

 

 

Program için gerekli toolbox nesneleri : 3 adet textbox, 4 adet radio button, 3 adet checkbox ve 2 adet button’dur.

 

Public Class Form1

 

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

        If RadioButton1.Checked Then

            TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

        End If

        If RadioButton2.Checked Then

            TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

        End If

        If RadioButton3.Checked Then

            TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

        End If

        If RadioButton4.Checked Then

            TextBox3.Text = Val(TextBox1.Text) / Val(TextBox2.Text)

        End If

    End Sub

 

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

        If CheckBox1.Checked Then

            TextBox3.Text = Val(TextBox1.Text) + Val(TextBox2.Text)

        End If

        If CheckBox2.Checked Then

            TextBox3.Text = Val(TextBox1.Text) - Val(TextBox2.Text)

        End If

        If CheckBox1.Checked And CheckBox2.Checked Then

            TextBox3.Text = Val(TextBox1.Text) * Val(TextBox2.Text)

        End If

    End Sub

End Class

 

 

AÇIKLAMA : Programımız ilk 2 textbox’a girilen sayıları seçilen radio button veya checkbox aracılığıyla 3. Textboxta göstermektedir.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Program için gerekli toolbox nesneleri : 1 adet listbox ve 1 adet button.

 

 

 

Public Class Form1

    Dim sayi As String

 

    Private Sub cmdekle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdekle.Click

        Dim lstrakamlar As New ArrayList

        Dim rastgele As New Random

        Dim i, j As Byte

 

        For i = 1 To 10

            lstrakamlar.Add(i)

        Next i

 

        ListBox1.Items.Clear()

        For j = 1 To 10

            Dim rakam As Byte = lstrakamlar.Item(rastgele.Next(0, lstrakamlar.Count))

            ListBox1.Items.Add(rakam)

        Next j

    End Sub

End Class

 

 

 

AÇIKLAMA : Programımızda button 1’e tıkladığımızda listbox penceresi içinde rastgele sayılar oluşmaktadır (10 tane)

 

 

 

 

Program için gerekli toolbox nesneleri: 2 adet textbox ve 1 adet button.

 

 

Public Class Form1

 

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

        TextBox2.Text = TextBox1.Text * TextBox1.Text

    End Sub

 

    Private Sub Button1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Button1.KeyPress

        If e.KeyChar = ChrW(Keys.Enter) Then

            ChrW(Keys.Enter)

        End If

 

    End Sub

End Class

 

 

 

AÇIKLAMA : Programımız 1.textbox kutusuna girilen rakamın karesini 2. Textbox’ta göstermektedir.

 

Programımız için gerekli toolbox nesneleri: 1 adet button.

 

 

Public Class Form1

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

 

    End Sub

 

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

        Dim yil As Integer

        yil = InputBox("yılı giriniz")

        If yil Mod 4 = 0 Then

            MsgBox(yil & "yılında subat ayı 29 ceker")

        Else

            MsgBox(yil & "yılında subat ayı 28 ceker")

 

        End If

 

    End Sub

End Class

 

AÇIKLAMA: Programımızda butona tıklandığında inputbox açılır ve yıl girilir daha sonra program girilen yılda şubat ayı kaç gün ise mesaj kutusunda gösterir.

 

Program için gerekli toolbox nesneleri: 2 adet textbox ve 1 adet buton.

 

Public Class Form1

 

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

        TextBox2.Font = New Font("verdana", Int(TextBox1.Text), FontStyle.Bold)

    End Sub

End Class

 

 

AÇIKLAMA: program textbox1’e girilen yazıyı textbox2’de değişik yazı şekliyle çıkartacaktır.

 

 

 

 

 

Program için gerekli toolbox nesneleri: 2 adet buton ve 1 adet label.

 

Public Class Form1

    Dim rastgele As New Random

    Dim tutulansayi As Integer = rastgele.Next(1, 100)

    Dim hak, tahmininiz As Byte

    Private Sub cmdtahmin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdtahmin.Click

        If hak = 0 Then cmdtahmin.Enabled = False

        tahmininiz = Val(InputBox("tahmininizi giriniz"))

        If (Val(tahmininiz) <= 100) And (Val(tahmininiz) >= 0) Then

            If tutulansayi < 100 Or tutulansayi >= 0 Then

                If tahmininiz < tutulansayi Then

                    lblmessage.Text = "daha büyük!" + Str(hak) + "hakkiniz kaldi"

                End If

                If tahmininiz > tutulansayi Then

                    lblmessage.Text = "daha küçük!" + Str(hak) + "hakkiniz kaldi"

                End If

                If tahmininiz = tutulansayi Then

                    lblmessage.Text = "tahmin doğru bravo !!!"

                End If

                If hak > 0 Then

                    hak = hak - 1

                Else

                    lblmessage.Text = "sayıyı bulamadınız. tutulan sayı= " & tutulansayi

 

                End If

            End If

        End If

    End Sub

 

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        hak = 4

    End Sub

 

    Private Sub cmdyenile_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdyenile.Click

        If hak = 0 Then cmdtahmin.Enabled = True

        hak = 4

        lblmessage.Text = "_"

    End Sub

End Class

 

 

AÇIKLAMA: program butona basıldığında inputbox penceresini açar sayı girilir eğer girilen sayı ile bilgisayarın tuttuğu sayı aynı ise tebrik eder sayı büyükse daha küçük küçükse daha büyük diye uyarı yapar 5 tahminde de bulunamazsa doğru cevap gösterilir.

 

 

Program için gerekli toolbox nesneleri: 1 adet combobox, 5 adet buton, 2 adet timer

Public Class Form1

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        MsgBox(ComboBox1.SelectedItem)

    End Sub

    Private Sub cmdekle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdekle.Click

        Dim i As Byte

        For i = 0 To 100

            If i Mod 2 = 0 Then

                ComboBox1.Items.Add(i)

            End If

        Next i

        ComboBox1.SelectedIndex = 0

    End Sub

    Private Sub cmdsil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdsil.Click

        ComboBox1.Items.Remove(ComboBox1.SelectedItem)

    End Sub

    Private Sub cmdTumunuSil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdTumunuSil.Click

        ComboBox1.Items.Clear()

        ComboBox1.Text = ""

    End Sub

    Private Sub cmdYavasEkle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdYavasEkle.Click

        tmrekle.Enabled = True

        tmrsil.Enabled = False

    End Sub

    Private Sub cmdYavasSil_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdYavasSil.Click

        tmrsil.Enabled = True

        tmrekle.Enabled = False

    End Sub

    Private Sub tmrekle_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrekle.Tick

        Static i As Byte

        i = i + 1

        ComboBox1.Items.Add(i)

        If i = 100 Then

            tmrekle.Enabled = False

        End If

    End Sub

    Private Sub tmrsil_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrsil.Tick

        Static i As Byte

        i = i + 1

        ComboBox1.Items.Remove(i)

        If i = 100 Then

            tmrsil.Enabled = False

        End If

    End Sub

End Class

 

AÇIKLAMA: Örneğimizde combobox içerisine değer ekleme ve silme olaylarını yaparız

 

Program için gerekli toolbox nesneleri:2 adet picturebox, 2 adet timer, 1 adet scrollbar, 1 adet buton.

 

Public Class Form1

    Dim f, g As Int32

    Private Sub cmdbasla_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbasla.Click

        PictureBox1.Top = 29

        PictureBox1.Left = 12

        PictureBox2.Top = 135

        PictureBox2.Left = 12

 

        Timer1.Enabled = True

        Timer2.Enabled = True

        Timer1.Interval = HScrollBar1.Value

        Timer2.Interval = HScrollBar1.Value

    End Sub

 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Randomize()

        g = Rnd(10) * 10

        PictureBox1.Left = PictureBox1.Left + g

        If PictureBox1.Left >= 800 Then

            Timer1.Enabled = False

            Timer2.Enabled = False

            MsgBox("kazanan sarı araba")

            Exit Sub

        End If

    End Sub

 

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

        Randomize()

        f = Rnd(10) * 10

        PictureBox2.Left = PictureBox2.Left + f

        If PictureBox2.Left >= 800 Then

            Timer1.Enabled = False

            Timer2.Enabled = False

            MsgBox("kazanan mavi araba")

            Exit Sub

        End If

    End Sub

 

    Private Sub HScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles HScrollBar1.Scroll

        Timer1.Interval = HScrollBar1.Value * 10

        Timer2.Interval = HScrollBar1.Value * 10

    End Sub

End Class

 

 

AÇIKLAMA: butona tıkladığımızda 2 resim kutusu rastgele hızda lineshape nesnesine doğru hareket eder hangisi daha önce gelirse yarışı kazanır.

 

 

 

 

 

 Program için gerekli toolbox nesneleri: 1 adet textbox, 1 adet buton 1 adet label ve 6 adet timer.

Public Class Form1

    Dim i, j, k, l, m, n, basla, bit

 

    Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged

 

    End Sub

 

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

        basla = Now

        Timer1.Enabled = True

        Timer2.Enabled = True

        Timer3.Enabled = True

        Timer4.Enabled = True

        Timer5.Enabled = True

    End Sub

 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Randomize()

        i = (Int(Rnd() * 10000))

        Label1.Text = i

        If i = TextBox2.Text Then

            bit = Now

            Label1.Text = "şifre=" & i & "   Başlangıç zamanı=" & basla & " bitiş zamanı=" & bit

            Timer5.Enabled = False

            Timer4.Enabled = False

            Timer3.Enabled = False

            Timer2.Enabled = False

            Timer1.Enabled = False

            Exit Sub

        End If

    End Sub

 

    Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

        Randomize()

        j = (Int(Rnd() * 10000))

        Label1.Text = i

        If j = TextBox2.Text Then

            bit = Now

            Label1.Text = "şifre=" & i & "   Başlangıç zamanı=" & basla & " bitiş zamanı=" & bit

            Timer5.Enabled = False

            Timer4.Enabled = False

            Timer3.Enabled = False

            Timer2.Enabled = False

            Timer1.Enabled = False

            Exit Sub

        End If

    End Sub

 

    Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick

        Randomize()

        k = (Int(Rnd() * 10000))

        Label1.Text = i

        If k = TextBox2.Text Then

            bit = Now

            Label1.Text = "şifre=" & i & "   Başlangıç zamanı=" & basla & " bitiş zamanı=" & bit

            Timer5.Enabled = False

            Timer4.Enabled = False

            Timer3.Enabled = False

            Timer2.Enabled = False

            Timer1.Enabled = False

            Exit Sub

        End If

    End Sub

 

    Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick

        Randomize()

        l = (Int(Rnd() * 10000))

        Label1.Text = i

        If l = TextBox2.Text Then

            bit = Now

            Label1.Text = "şifre=" & i & "   Başlangıç zamanı=" & basla & " bitiş zamanı=" & bit

            Timer5.Enabled = False

            Timer4.Enabled = False

            Timer3.Enabled = False

            Timer2.Enabled = False

            Timer1.Enabled = False

            Exit Sub

        End If

    End Sub

 

    Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick

        Randomize()

        m = (Int(Rnd() * 10000))

        Label1.Text = i

        If m = TextBox2.Text Then

            bit = Now

            Label1.Text = "şifre=" & i & " Başlangıç zamanı=" & basla & " bitiş zamanı=" & bit

            Timer5.Enabled = False

            Timer4.Enabled = False

            Timer3.Enabled = False

            Timer2.Enabled = False

            Timer1.Enabled = False

            Exit Sub

        End If

    End Sub

 

    Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick

        Randomize()

        n = (Int(Rnd() * 10000))

        Label1.Text = i

        If n = TextBox2.Text Then

            bit = Now

            Label1.Text = "şifre=" & i & " Başlangıç zamanı=" & basla & " bitiş zamanı =" & bit

            Timer5.Enabled = False

            Timer4.Enabled = False

            Timer3.Enabled = False

            Timer2.Enabled = False

            Timer1.Enabled = False

            Exit Sub

        End If

    End Sub

End Class

 

 

Açıklama: program bilgisayarda rastgele sayılar oluşturur ve girilen sayıyla eşdeğer bir sayı bulmaya çalışır timer sayısı ne kadar çok ise o kadar kısa sürede bulur.

 

 

Program için gerekli toolbox nesneleri:1 adet textbox ( multiline = true ) ve 1 adet buton.

Public Class Form1

    Private Sub cmdbul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdbul.Click

        Dim i, cumlesay As Integer

 

        For i = 1 To Len(TextBox1.Text)

            If Mid(TextBox1.Text, i, 1) = "." Then cumlesay = cumlesay + 1

        Next

        MsgBox("Cümle Sayısı= " & cumlesay)

    End Sub

End Class

 

Açıklama: textbox içine girilen metinde kaç tane cümle olduğunu mesaj penceresinde gösterir.

Program için gerekli toolbox nesneleri: 1 adet textbox 1 adet buton.

Public Class Form1

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

        Dim i As Integer

                    For i = 0 To 255

                TextBox1.Text = TextBox1.Text + " " & i & " = " & Chr(i)

            Next

                End Sub

End Class

Açıklama: butona bastığımızda 255 adet sayı oluşturur.

 

 

Program için gerekli toolbox nesneleri: 1 adet textbox.

Public Class Form1

 

    Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress

        Static sayi, s1, s2 As Integer

        Dim sonuc As Integer

        If e.KeyChar = Chr(13) Then

            sayi = sayi + 1

            If sayi = 1 Then

                s1 = Val(TextBox1.Text)

                TextBox1.Text = ""

            Else

                If sayi = 2 Then

                    s2 = Val(TextBox1.Text)

                    TextBox1.Text = ""

                    If Val(s1) > Val(s2) Then

                        sonuc = s1 - s2

                    Else

                        sonuc = s2 - s1

                    End If

                    TextBox1.Text = sonuc

                    sayi = 0

                    s1 = 0

                    s2 = 0

                End If

            End If

        End If

    End Sub

End Class

Açıklama: yazı kutusuna girilen sayıların büyüğünden küçüğünü çıkartır 2. sayı girilirken enter tuşu kullanılır.

 

 
   
 

Bilişim Teknolojileri Portalı
Telif Hakları ©2007 - 2012, Onur Ateş'e Aittir.
© 2010 Onur Ateş
Bu web sitesi ücretsiz olarak Bedava-Sitem.com ile oluşturulmuştur. Siz de kendi web sitenizi kurmak ister misiniz?
Ücretsiz kaydol