Konu 14: Treeview Uygulaması Kullanılarak Yapılmış Dizin Listeleme Programı

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'drive dizisine bilgisayarda bulunan suruculeri listeler
        Dim drive() As String = System.IO.Directory.GetLogicalDrives
        For i As Integer = 0 To UBound(drive)
            ComboBox1.Items.Add(drive(i))
        Next
        ComboBox1.SelectedIndex = 0
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        On Error Resume Next
        TreeView1.Nodes.Clear()
        Dim surucu As String = ComboBox1.SelectedItem
        Dim klasor As String
        'surucu icersinde bulunan her bir klasoru teker teker gezer
        For Each klasor In My.Computer.FileSystem.GetDirectories(surucu)
            Dim sonuc As String
            'bulunan klasorun yolundan dizin ismini cikartir
            sonuc = klasor.Remove(0, surucu.Length)
            'treeviewa ekler
            TreeView1.Nodes.Add(sonuc)
        Next
    End Sub
End Class

Konu 13: Treeview, Listview, İmagelist Özellikleri Ve Kullanımı

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        TreeView1.Nodes.Add(TextBox1.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        TreeView1.SelectedNode.Nodes.Add(TextBox1.Text)
    End Sub

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

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

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        TreeView1.SelectedNode.Text = TextBox1.Text
    End Sub

    Private Sub TreeView1_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles TreeView1.AfterSelect
        'secilen dugumun text ve fullpath bilgisini labellara yazar
        Label1.Text = e.Node.Text
        Label2.Text = e.Node.FullPath
        'listviewi temizler
        ListView1.Items.Clear()
        'treeviewda secilen bir dugumun alt dugumleri varsa
        'for dongusuyle hepsini gezer
        For i As Integer = 0 To TreeView1.SelectedNode.Nodes.Count - 1
            'secilen dugumun alt dugumlerini listviewa ekler
            ListView1.Items.Add(TreeView1.SelectedNode.Nodes(i).Text, TreeView1.SelectedNode.Nodes(i).ImageIndex)
            'eklenen nesne icin detay gorunumunde boyut ve tür bilgisini yazar
            ListView1.Items(i).SubItems.Add("10")
            ListView1.Items(i).SubItems.Add("parca")
        Next

    End Sub
    Dim acik As Boolean
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        If acik = True Then
            'treeview dugumlerini kapatır
            TreeView1.CollapseAll()
            acik = False
        Else
            'treeview dugumlerini acar
            TreeView1.ExpandAll()
            acik = True
        End If
    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TreeView1.SelectedNode.ImageIndex = Val(TextBox2.Text)
    End Sub
    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Select Case ComboBox1.SelectedItem
            Case "detay"
                ListView1.View = View.Details
            Case "buyuk"
                ListView1.View = View.LargeIcon
            Case "liste"
                ListView1.View = View.List
            Case "kucuk"
                ListView1.View = View.SmallIcon
            Case "tile"
                ListView1.View = View.Tile
        End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'listviewin detay gorunumune ad,boyut,tur kolonlarını ekler
        ListView1.Columns.Add("adı", 100, HorizontalAlignment.Left)
        ListView1.Columns.Add("boyut", 50, HorizontalAlignment.Left)
        ListView1.Columns.Add("tür", 100, HorizontalAlignment.Left)
    End Sub
End Class

Konu 12: Listboxlar, Checkedlistboxlar, Comboboxlar Ve Özellikleri

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1
    Dim dizi() As String
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For i As Integer = 0 To ListBox1.SelectedItems.Count - 1
            ListBox2.Items.Add(ListBox1.SelectedItems.Item(i))
        Next
        For i As Integer = ListBox1.SelectedItems.Count - 1 To 0 Step -1
            ListBox1.Items.Remove(ListBox1.SelectedItems.Item(i))
        Next
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        ReDim dizi(ListBox1.SelectedItems.Count - 1)
        ListBox1.SelectedItems.CopyTo(dizi, 0)
    End Sub
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        For i As Integer = 0 To UBound(dizi)
            ListBox2.Items.Add(dizi(i))
        Next
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Label1.Text = ListBox3.SelectedItem
    End Sub
    Dim renkler() As String
    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        ReDim renkler(ListBox4.SelectedItems.Count - 1)
        ListBox4.SelectedItems.CopyTo(renkler, 0)

        Dim rastgele As Integer = Rnd() * UBound(renkler)
        Dim secilen As String = renkler(rastgele)

        Select Case secilen
            Case "mavi"
                Me.BackColor = Color.Blue
            Case "kırmızı"
                Me.BackColor = Color.Red
            Case "yeşil"
                Me.BackColor = Color.Green
            Case "siyah"
                Me.BackColor = Color.Black
            Case "beyaz"
                Me.BackColor = Color.White
            Case "aqua"
                Me.BackColor = Color.Aqua
            Case "mor"
                Me.BackColor = Color.Purple
            Case "haki"
                Me.BackColor = Color.Khaki
            Case "sarı"
                Me.BackColor = Color.Yellow
            Case "turkuaz"
                Me.BackColor = Color.Turquoise
            Case Else
                Me.BackColor = Color.AliceBlue
        End Select
    End Sub
    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        For i As Integer = 0 To ListBox1.Items.Count - 1
            ListBox2.Items.Add(ListBox1.Items.Item(i))
        Next
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        CheckedListBox1.CheckOnClick = True
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        'MsgBox(CheckedListBox1.SelectedItem)
        For i As Integer = 0 To CheckedListBox1.CheckedItems.Count - 1
            ListBox5.Items.Add(CheckedListBox1.CheckedItems.Item(i))
        Next
    End Sub

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

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        ComboBox1.SelectedIndex = Val(TextBox1.Text)
    End Sub
End Class

Konu 11: Textbox Özellikleri, String İşlemleri, Listbox Özellikleri

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        'TextBox2.Text &= TextBox1.Text & Chr(13) & Chr(10)
        TextBox2.Text &= TextBox1.Text & vbCrLf
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim dizi() As String
        dizi = TextBox2.Lines
        For i As Integer = 0 To UBound(dizi)
            MsgBox(dizi(i))
        Next
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        ListBox1.Items.Add("Düzce")
        For i As Integer = 0 To 9
            ListBox1.Items.Add("sayı " & i + 1)
        Next
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ListBox1.Items.Add(TextBox3.Text)
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim gunler() As String = {"ptesi", "salı", "cars", "pers", "cuma", "ctesi", "pazar"}
        For Each gun As String In gunler
            ListBox2.Items.Add(gun)
        Next
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        For Each ctr As Control In Me.Controls
            ctr.BackColor = Color.Aqua
        Next
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        ListBox2.Items.Insert(2, "ara gun")
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        ListBox2.Items.Insert(Val(TextBox4.Text), TextBox5.Text)
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        'Dim indis As Integer
        'indis = ListBox2.Items.IndexOf(TextBox6.Text)
        'MsgBox(indis)
        'ListBox2.SelectedIndex = 2
        If ListBox2.Items.IndexOf(TextBox6.Text) > -1 Then
            ListBox2.SelectedIndex = ListBox2.Items.IndexOf(TextBox6.Text)
        Else
            MsgBox("kayıt bulunamadı")
        End If

    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        ListBox3.Sorted = True
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        ListBox4.Items.Clear()
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        ListBox4.Items.Remove(TextBox7.Text)
    End Sub

    Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
        ListBox4.Items.RemoveAt(ListBox4.SelectedIndex)
    End Sub

    Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
        MsgBox(ListBox4.Items.Count)
    End Sub

    Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
        MsgBox(ListBox5.Items.Item(2))
    End Sub

    Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
        If ListBox5.SelectedIndex > -1 Then
            ListBox6.Items.Add(ListBox5.SelectedItem)
            ListBox5.Items.RemoveAt(ListBox5.SelectedIndex)
        End If
    End Sub

End Class

Konu 10: Butonlar, Labellar, Linklabellar, Textboxlar Ve Çok Kullanılan Özellikleri

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Button3.Image = Image.FromFile("../../resources/gb.jpg")
        Button3.TextAlign = ContentAlignment.BottomCenter
        Button3.ImageAlign = ContentAlignment.TopCenter
    End Sub
    Private Sub Label1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.DoubleClick
        MsgBox("selam")
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        LinkLabel1.Text = "google istediğinizi bulur"
        LinkLabel1.LinkArea = New LinkArea(0, 6)
        'isimler isminde otomatik tamamlama koleksiyonu olusturulur
        Dim isimler As New AutoCompleteStringCollection
        'elemanilari belirlenir
        isimler.Add("ahmet")
        isimler.Add("mehmet")
        'textboxın oto tamamlama kullanıcı kaynagı isimler olarak belirlenir
        TextBox1.AutoCompleteCustomSource = isimler
        'textboxın oto tamamlama kaynagı; kullanıcı kaynagı olarak belirlenir
        TextBox1.AutoCompleteSource = AutoCompleteSource.CustomSource
        'textboxın oto tamamlama modu belirlenir
        TextBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
        'boylelikle textboxa isim girerken otomatik tamamlama yapabilmesi saglanir
    End Sub
    Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked
        System.Diagnostics.Process.Start("http://www.google.com")
        'System.Diagnostics.Process.Start("mailto:adisoyadi@gmail.com")
        'System.Diagnostics.Process.Start("notepad")
        'System.Diagnostics.Process.Start("calc")
        LinkLabel1.LinkVisited = True
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        TextBox1.Text = "o "" merhaba"" dedi "
        TextBox1.Text = "o " & Chr(34) & " merhaba" & Chr(34) & " dedi"
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        If TextBox1.ReadOnly = True Then
            TextBox1.ReadOnly = False
        Else
            TextBox1.ReadOnly = True
        End If
    End Sub

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

    End Sub
    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        TextBox2.Copy()
    End Sub
    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        TextBox2.Paste()
    End Sub
    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        TextBox2.Undo()
    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        'geri al hafızasını (historyi temizler)
        TextBox2.ClearUndo()

    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        TextBox2.AppendText(TextBox1.Text)
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        TextBox2.Text = ""
        TextBox2.Clear()
    End Sub
End Class

Konu 9: Not defteri, basit html editörü örneği

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1

    Private Sub ac_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ac.Click
        ofd.Title = "dosya aç"
        ofd.Filter = "Metin dosyaları (*.txt)|*.txt|resim dosyası (*.jpg)|*.jpg|tüm dosyalar|*.*"
        ofd.FilterIndex = 1
        ofd.FileName = ""
        ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        'ofd.ShowDialog()
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim yol As String
            yol = ofd.FileName
            TextBox1.Text = My.Computer.FileSystem.ReadAllText(yol)

        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        sfd.Title = "kaydet"
        sfd.Filter = "Metin dosyaları (*.txt)|*.txt|resim dosyası (*.jpg)|*.jpg|tüm dosyalar|*.*"
        sfd.FilterIndex = 1
        sfd.FileName = ""
        sfd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim yol As String
            yol = sfd.FileName
            My.Computer.FileSystem.WriteAllText(yol, TextBox1.Text, False)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cd.FullOpen = True
        If cd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Me.BackColor = cd.Color
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cd.FullOpen = True
        If cd.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextBox1.ForeColor = cd.Color
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        fd.ShowColor = True
        If fd.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextBox1.Font = fd.Font
            TextBox1.ForeColor = fd.Color
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim secilen As String
        secilen = TextBox1.SelectedText
        secilen = "<b>" & secilen & "</b>"
        TextBox1.SelectedText = secilen

    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        Fbd.Description = "klasor gezin"
        Fbd.ShowNewFolderButton = True
        If Fbd.ShowDialog = Windows.Forms.DialogResult.OK Then
            MsgBox(Fbd.SelectedPath)
        End If
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        ofd.Title = "dosya aç"
        ofd.Filter = "resim dosyası (*.jpg)|*.jpg|tüm dosyalar|*.*"
        ofd.FilterIndex = 1
        ofd.FileName = ""
        ofd.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        'ofd.ShowDialog()
        If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim yol As String
            yol = ofd.FileName
            PictureBox1.ImageLocation = yol

        End If
    End Sub

    Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
        Dim secilen As String
        secilen = TextBox1.SelectedText
        secilen = "<html>" & vbCrLf & vbTab & "<head>" & vbCrLf & vbTab & vbTab & "<title>" & vbCrLf & vbTab & vbTab & vbTab & vbCrLf & vbTab & vbTab & "</title>" & vbCrLf & vbTab & "</head>" & vbCrLf & vbTab & "<body>" & vbCrLf & vbTab & vbTab & secilen & vbCrLf & vbTab & "</body>" & vbCrLf & "</html>"
        TextBox1.SelectedText = secilen
    End Sub

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
        cd.FullOpen = True
        Dim renk As Color
        If cd.ShowDialog = Windows.Forms.DialogResult.OK Then

            renk = cd.Color
        End If
        Dim secilen As String
        secilen = TextBox1.SelectedText
        secilen = "<font color='#" & Strings.Right(Hex(renk.ToArgb), 6) & "'>" & secilen & "</font>"
        TextBox1.SelectedText = secilen

    End Sub

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
        Dim yazi As String
        yazi = vbTab & vbTab & "<select>"

        Dim kategori() As String = Split(TextBox2.Text, vbCrLf)
        For i As Integer = 0 To UBound(kategori)
            If kategori(i) <> "" Then
                yazi &= vbCrLf & vbTab & vbTab & vbTab & "<option value=" & kategori(i) & ">" & kategori(i) & "</option>"
            End If
        Next
        yazi &= vbCrLf & vbTab & vbTab & "</select>"
        TextBox1.SelectedText = yazi
    End Sub

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
        WebBrowser1.DocumentText = TextBox1.Text
    End Sub

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
        Dim secilen As String
        secilen = TextBox1.SelectedText
        secilen = "<img src='" & PictureBox1.ImageLocation & "' width='200'>"
        TextBox1.SelectedText = secilen
    End Sub

End Class

Konu 8: Menu Strip,Tool Strip, Tool Stripcontainer, Contextmenu, Status Strip

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1
    Private Sub YeniToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YeniToolStripMenuItem.Click
        MsgBox("yeni")
    End Sub
    Private Sub ToolStripTextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ToolStripTextBox1.KeyPress
        If e.KeyChar = Chr(13) Then
            MsgBox(ToolStripTextBox1.Text)
        End If
    End Sub
    Private Sub cb1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cb1.SelectedIndexChanged
        'renk degistir

        Select Case cb1.SelectedItem
            Case "kırmızı"
                Me.BackColor = Color.Red
            Case "yeşil"
                Me.BackColor = Color.Green
            Case "mavi"
                Me.BackColor = Color.Blue
            Case "sarı"
                Me.BackColor = Color.Yellow
            Case "beyaz"
                Me.BackColor = Color.White
        End Select
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        cb1.Items.Add("kırmızı")
        cb1.Items.Add("yeşil")
        cb1.Items.Add("mavi")
        cb1.Items.Add("sarı")
        cb1.Items.Add("beyaz")

        Dim tarih As Date
        tarih = Now
        pb1.Maximum = 24
        pb1.Value = tarih.Hour
        tslabel1.Text = tarih
    End Sub

    Private Sub ToolStrip1_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles ToolStrip1.ItemClicked

    End Sub

    Private Sub ToolStripButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ToolStripButton1.Click
        MsgBox("buton")
    End Sub

    Private Sub ToolStripContainer2_ContentPanel_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripContainer2.ContentPanel.Load

    End Sub

End Class

Konu 38: Ek Anlatım (Nesne Oluşturma, Olay Atama, Diziler)

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1
    Dim butonlar(2, 2) As Button
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        For j As Integer = 0 To 2
            For i As Integer = 0 To 2
                Dim btn As New Button
                btn.Width = 60
                btn.Height = 30
                btn.Left = 65 * i + 10
                btn.Top = 100 + 30 * j
                btn.Text = "merhaba"
                btn.Name = j & i
                Me.Controls.Add(btn)
                AddHandler btn.Click, AddressOf btnkilik
                butonlar(j, i) = btn
            Next
        Next
    End Sub

    Private Sub btnkilik(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim isim As String
        isim = sender.name

        For j As Integer = 0 To 2
            For i As Integer = 0 To 2
                If butonlar(j, i).Name <> isim And (i = 1 Or j = 1) Then
                    butonlar(j, i).BackColor = Color.FromArgb(255, Rnd() * 255, Rnd() * 255, Rnd() * 255)
                End If
            Next
        Next
    End Sub

End Class

Konu 7: Open File D., Savefile D., Font D., Color D., Folderbrowser D., Seçilen Yazı Üzerinde İşlem Yapma, Resim Açma

Örnek Uygulama

Ekran Görüntüsü

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OfD1.Title = "metin dosyası aç"
        OfD1.Filter = "metin dosyaları (*.txt)|*.txt|resim dosyaları (*.jpg)|*.jpg|Tüm dosyalar (*.*)|*.*"
        OfD1.FilterIndex = 1
        OfD1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        'OfD1.ShowDialog()
        If OfD1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim yol As String
            yol = OfD1.FileName
            TextBox1.Text = My.Computer.FileSystem.ReadAllText(yol)
        End If
    End Sub

    Private Sub kaydet_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles kaydet.Click
        sfd1.Title = "metin dosyası kaydet"
        sfd1.Filter = "metin dosyaları (*.txt)|*.txt|web sayfası (*.htm)|*.htm|resim dosyaları (*.jpg)|*.jpg|Tüm dosyalar (*.*)|*.*"
        sfd1.FilterIndex = 2
        sfd1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
        'OfD1.ShowDialog()
        If sfd1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Dim yol As String
            yol = sfd1.FileName
            My.Computer.FileSystem.WriteAllText(yol, TextBox1.Text, False)
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        cd1.FullOpen = True
        If cd1.ShowDialog = Windows.Forms.DialogResult.OK Then
            Me.BackColor = cd1.Color
        End If
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        cd1.FullOpen = True
        If cd1.ShowDialog = Windows.Forms.DialogResult.OK Then
            'Me.ForeColor = cd1.Color
            TextBox1.ForeColor = cd1.Color
        End If
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        fd1.ShowColor = True
        If fd1.ShowDialog = Windows.Forms.DialogResult.OK Then
            TextBox1.Font = fd1.Font
            TextBox1.ForeColor = fd1.Color
        End If
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Dim deger As String
        deger = TextBox1.SelectedText
        deger = "<b>" & deger & "</b>"
        TextBox1.SelectedText = deger
    End Sub

    Private Sub dosya_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dosya.Click
        fbd1.Description = "klasor gezgini"
        fbd1.ShowNewFolderButton = True
        If fbd1.ShowDialog = Windows.Forms.DialogResult.OK Then
            MsgBox(fbd1.SelectedPath)
        End If
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        OfD1.Title = "resim aç"
        OfD1.Filter = "resim dosyaları (*.jpg)|*.jpg|Tüm dosyalar (*.*)|*.*"
        OfD1.FilterIndex = 1
        OfD1.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyPictures
        If OfD1.ShowDialog = Windows.Forms.DialogResult.OK Then
            PictureBox1.ImageLocation = OfD1.FileName
        End If

    End Sub
End Class

Konu 37: Eş bulma oyunu örneği

Örnek Uygulama

Ekran Görüntüsü

   

Public Class Form1
    Dim btnler(3, 3) As Button
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        tahtaolustur()
        oyunubaslat()
    End Sub

    Dim kactane As Integer
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        kactane = ((UBound(btnler, 1) + 1) * (UBound(btnler, 2) + 1)) / 2
        For i As Integer = 1 To kactane
            For j As Integer = 1 To 2
                Dim x, y As Integer

                Do
                    x = Rnd() * UBound(btnler, 2)
                    y = Rnd() * UBound(btnler, 1)
                Loop Until btnler(y, x).Name = ""

                btnler(y, x).Name = i

            Next
        Next
    End Sub
    Dim onceki As Button
    Dim sayac As Integer = 0
    Private Sub olay(ByVal sender As System.Object, ByVal e As System.EventArgs)
        sender.Text = sender.Name
        If IsNothing(onceki) Then
            onceki = sender
        Else
            'ilk butonla eslesiyor mu?
            If onceki.Name = sender.Name Then
                sayac += 1

                onceki.Enabled = False
                sender.Enabled = False
                onceki.BackColor = Color.Aqua
                sender.BackColor = Color.Aqua
                If sayac = kactane Then
                    seviyeartir()
                End If
            Else
                Me.Enabled = False
                Application.DoEvents()
                Threading.Thread.Sleep(1000)
                onceki.Text = ""
                sender.Text = ""
                Me.Enabled = True
            End If

            onceki = Nothing
        End If
    End Sub

    Sub tahtaolustur()
        For i As Integer = 0 To UBound(btnler, 1)
            For j As Integer = 0 To UBound(btnler, 2)
                Dim btn As New Button
                Me.Controls.Add(btn)
                btn.Top = 50 * i + 50
                btn.Left = 50 * j + 10
                btn.Width = 45
                btn.Height = 45
                btnler(i, j) = btn
                AddHandler btn.Click, AddressOf olay
            Next
        Next
        Me.Width = UBound(btnler, 2) * 50 + 70
        Me.Height = UBound(btnler, 1) * 50 + 150
    End Sub

    Sub seviyeartir()
        MsgBox("aferin")
        sayac = 0
        For i As Integer = 0 To UBound(btnler, 1)
            For j As Integer = 0 To UBound(btnler, 2)
                btnler(i, j).Dispose()
            Next
        Next

        ReDim btnler(Math.Sqrt(kactane * 2) + 1, Math.Sqrt(kactane * 2) + 1)
        tahtaolustur()
        oyunubaslat()

    End Sub

    Sub oyunubaslat()
        kactane = ((UBound(btnler, 1) + 1) * (UBound(btnler, 2) + 1)) / 2
        For i As Integer = 1 To kactane
            For j As Integer = 1 To 2
                Dim x, y As Integer
git:
                x = Rnd() * UBound(btnler, 2)
                y = Rnd() * UBound(btnler, 1)
                If btnler(y, x).Name = "" Then
                    btnler(y, x).Name = i
                Else
                    GoTo git
                End If

            Next
        Next
    End Sub

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