Skip to content

Instantly share code, notes, and snippets.

@canokay
Created April 24, 2019 10:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canokay/a60da847d92bf3dbf8fe2bb7b8476a4b to your computer and use it in GitHub Desktop.
Save canokay/a60da847d92bf3dbf8fe2bb7b8476a4b to your computer and use it in GitHub Desktop.

Visual Basic Vize Çalışması - Uygulamalar

Hafta 2 - Database Bağlantısı

Uygulama 1

Imports System.Data.OleDb

Public Class frmMain

    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim bag As String = "Provider= Microsoft.Jet.Oledb.4.0; Data Source=veritabani.mdb"
        Dim sorgu As String = "select * from kitap"
        Dim ybag As New OleDbConnection(bag)
        Dim yerial As New OleDbDataAdapter(sorgu, ybag)
        Dim ytablo As New DataTable()
        Dim yol As New DataSet()
        yerial.Fill(yol, "sanalTable")
        yol.Tables.Add(ytablo)
        BindingSource1.DataSource = yol
        BindingSource1.DataMember = yol.Tables(0).TableName
        DataGridView1.DataSource = BindingSource1
        TextBox1.DataBindings.Add("text", BindingSource1, "kitapadi")
        TextBox2.DataBindings.Add("text", BindingSource1, "adeti")
        TextBox3.DataBindings.Add("text", BindingSource1, "fiyati")
    End Sub
End Class

Uygulama 2

Imports System.Data.OleDb
Public Class frmMain
    Dim baglanti As New OleDbConnection("Provider= Microsoft.Jet.Oledb.4.0; Data Source=C:\veritabani.mdb")

    Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

    End Sub
End Class

Hafta 4 - dll

dll_deneme/Class1.vb

Public Class Class1
    Dim Sonuc As Integer

    Function HesapMakinesi(ByVal IslemTuru As String, ByVal sayi1 As String, ByVal sayi2 As String)
        If IslemTuru = "+" Then
            Sonuc = sayi1 + sayi2
        End If
        If IslemTuru = "-" Then
            Sonuc = sayi1 - sayi2
        End If
        If IslemTuru = "*" Then
            Sonuc = sayi1 * sayi2
        End If
        If IslemTuru = "/" Then
            Sonuc = sayi1 / sayi2
        End If
        Return Sonuc
    End Function

End Class

maas_hesaplama_dll/Class1.vb

Public Class Class1

    Function Hesapla(ByVal burut_maas As Integer)
        Dim kesintiler As Integer = (burut_maas * 0.35)
        Dim sonuc As Integer = burut_maas - kesintiler

        Return sonuc
    End Function

End Class

uygulama1

Public Class Form1

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

    End Sub

    Sub deger()

    End Sub

End Class

uygulama2

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim nesne_ismi As New Class1()
        nesne_ismi.deneme(InputBox("Değer Girin: ", "Class Uygulaması", " ", 120, 120), InputBox("2. Değer Girin: ", "Class Uygulaması", " ", 120, 120))
    End Sub
End Class

uygulama3

Public Class Form1

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

        Dim sonuc As New Class1()
        sonuc.ortalama(Int(TextBox1.Text), Int(TextBox2.Text))
    End Sub

End Class

uygulama4

Public Class Form1

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

    End Sub

    Private Sub btn_result_Click(sender As Object, e As EventArgs) Handles btn_result.Click
        Dim obj As New daire()
        obj.yaricap = Val(TextBox1.Text)
        Label2.Text = "Dairenin Alanı: " + CStr(obj.alan)
        Label3.Text = "Dairenin Çevresi: " + CStr(obj.cevre)
    End Sub
End Class

uygulama6

Public Class Form1

    Private Sub btn_result_Click(sender As Object, e As EventArgs) Handles btn_result.Click
        Dim obj As New dll_deneme.Class1()
        MsgBox(obj.HesapMakinesi("+", 20, 10))
    End Sub
End Class

Hafta 5 - dll (Tekrardan)

dll_deneme/Class1.vb

Public Class Class1
    Dim Sonuc As Integer

    Function HesapMakinesi(ByVal IslemTuru As String, ByVal sayi1 As String, ByVal sayi2 As String)
        If IslemTuru = "+" Then
            Sonuc = sayi1 + sayi2
        End If
        If IslemTuru = "-" Then
            Sonuc = sayi1 - sayi2
        End If
        If IslemTuru = "*" Then
            Sonuc = sayi1 * sayi2
        End If
        If IslemTuru = "/" Then
            Sonuc = sayi1 / sayi2
        End If
        Return Sonuc
    End Function

End Class

dll_NotHesaplama/Class1.vb

Public Class Class1

    Function hesapla(ByVal vize1 As Integer, ByVal vize2 As Integer, ByVal final As Integer)
        Return (vize1 * 0.2) + (vize1 * 0.2) + (final * 0.6)
    End Function

End Class

uygulama1

Public Class Form1

    Private Sub btn_result_Click(sender As Object, e As EventArgs) Handles btn_result.Click


        'Dim nesne_ismi As New DLL_deneme.Class1()
        'MsgBox(nesne_ismi.HesapMakinesi("+", 10, 2))


        'Module2
        'Dim sonuc As Integer
        'sonuc = WinExec("c:\Windows\System32\NotePad.exe", 9)

        'Module3
        Dim yolu As String
        Dim uzun As Integer
        yolu = ".........."
        uzun = GetWindowsDirectory(yolu, Len(yolu))
        MessageBox.Show(yolu)

    End Sub
End Class

uygulama2

Public Class Form1
    '+Vize final yapılcak.
    '+Büt 70 altı kalacak btn basılınca word yada excel açılcak. 
    'Inputla alınan program ismine göre. Buton tıklanınca program kapatılcak. 
    'Açılacak olan programlar veya makine kapatacak program api ile yapılcak.
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lblButunleme.Visible = False
        tbButunleme.Visible = False

    End Sub

    Private Sub btn_result_Click(sender As Object, e As EventArgs) Handles btn_result.Click
        Dim vize1 As Integer = Convert.ToInt32(tbVize1.Text)
        Dim vize2 As Integer = Convert.ToInt32(tbVize2.Text)
        Dim final As Integer = Convert.ToInt32(tbFinal.Text)

        Dim nesne_ismi As New dll_NotHesaplama.Class1()
        Dim sonuc As Integer = nesne_ismi.hesapla(vize1, vize2, final)
        MsgBox(sonuc)
        If sonuc <= 70 Then
            lblButunleme.Visible = True
            tbButunleme.Visible = True
        End If
    End Sub
End Class

Hafta6

ortalama_dll/Class1.vb

Public Class Class1

    Function hesapla(ByVal vize As Integer, ByVal final As Integer)
        Return (vize * 0.4) + (final * 0.6)
    End Function

End Class

uygulama1

Imports System
Imports System.Xml
Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim doc As New XmlDataDocument()
        doc.Load("c:\deneme1.xml")
        Dim liste As XmlNodeList = doc.GetElementsByTagName("isci")
        Dim isci As XmlNode
        For Each isci In liste
            Dim sicil As String = isci.Attributes("sicil").Value
            Dim ad As String = isci("ad").FirstChild.Value
            Dim ucret As String = isci("ucret").FirstChild.Value
            Dim gorev As String = isci("gorev").FirstChild.Value
            ListBox1.Items.Add("Sicil= " & sicil)
            ListBox1.Items.Add("ad= " & ad)
            ListBox1.Items.Add("ucret= " & ucret)
            ListBox1.Items.Add("gorev= " & gorev)
            ListBox1.Items.Add("-------")

        Next


    End Sub
End Class

uygulama2

Imports System.Data.OleDb

Public Class Form1
    Dim command As New OleDbCommand



    Private Sub btn_Save_Click(sender As Object, e As EventArgs) Handles btn_Save.Click
        Dim vize As Integer = CInt(TextBox1.Text)
        Dim final As Integer = CInt(TextBox2.Text)
        Dim nesne_ismi As New Class1(vize, final)
        Dim ortalama As Integer = nesne_ismi.hesapla()
        lblSonuc.Text = ortalama
        lblSonuc.Visible = True
        Label3.Visible = True
    End Sub


    Private Sub db_to_xml_Click(sender As Object, e As EventArgs) Handles db_to_xml.Click
        Dim con As New OleDbConnection("Provider= Microsoft.Jet.Oledb.4.0; Data Source=veritabani.mdb")

        con.Open()

        command.Connection = con
        command.CommandType = CommandType.Text
        command.CommandText = "INSERT INTO  (vize,final,ortalama) values (" + vize + "," + final + "," + ortalama + "," + ")"
        command.ExecuteNonQuery()

        con.Close()

    End Sub

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        lblSonuc.Visible = False
        Label3.Visible = False

    End Sub
End Class

Hafta7 (Api)

uygulama1

Imports Microsoft.Office.Interop
Public Class Form1
    Dim word_uygulama As New Word.Application
    Dim word_dokuman As New Word.Document
    Private Sub btn_word_open_Click(sender As Object, e As EventArgs) Handles btn_word_open.Click
        word_dokuman = word_uygulama.Documents.Add
        word_uygulama.Visible = True
    End Sub

    Private Sub word_InsertAfter_Click(sender As Object, e As EventArgs) Handles word_InsertAfter.Click
        word_dokuman.Range().InsertAfter("Okay")
    End Sub

    Private Sub word_InsertBefore_Click(sender As Object, e As EventArgs) Handles word_InsertBefore.Click
        word_dokuman.Range().InsertBefore("Can ")
    End Sub

    Private Sub word_Paragraphs_add_Click(sender As Object, e As EventArgs) Handles word_Paragraphs_add.Click
        word_dokuman.Paragraphs.Add()
        word_dokuman.Range().InsertAfter("9 eylül üni lorem iplusum ")
    End Sub
End Class

uygulama2

Imports Microsoft.Office.Interop

Public Class Form1

    Dim word_uygulama As New Word.Application
    Dim word_dokuman As New Word.Document
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        word_dokuman = word_uygulama.Documents.Add
        word_uygulama.Visible = True
        word_dokuman.Range().InsertAfter(TextBox1.Text + " " + TextBox2.Text + " " + TextBox3.Text + " " + TextBox4.Text)
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        word_dokuman.Paragraphs.Add()
        word_dokuman.Range().InsertAfter("Öğrenci Bilgileri")
    End Sub

    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        word_dokuman.Paragraphs.Add()
        word_dokuman.Range().InsertAfter("9 eylül üni lorem iplusum ")
        word_dokuman.Paragraphs.Add()
        word_dokuman.Range().InsertAfter("İMYO")
        word_dokuman.Paragraphs.Add()
        word_dokuman.Range().InsertAfter("Bilgisayar Programcılığı Bölümü")
    End Sub

    Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
        RichTextBox1.Text = word_dokuman.Range().Text
        word_uygulama.Quit()
    End Sub

    Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
        RichTextBox1.Text = word_dokuman.StoryRanges.Application.Selection.Text
    End Sub

    Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
        word_dokuman = word_uygulama.Documents.Open(TextBox1.Text)
    End Sub
End Class

uygulama3

Public Class Form1
    'soru: imyo muhasebe vergi iadesi hesaplayan program istedi.
    '+İstekler: Hesaba dahil edilecek olan fiş sayısı input ile belirlenecek. 
    '+belirlenen sayı kadar vergi iadesi için aşağıdaki bilgiler girilcek.
    '+1. tarih
    '+2. fiş alınan yer
    '+3. miktarı
    'değerler alındıktan sonra kişinin net maaşına fişlerin toplamının 30% ilave edilerek ödeme yapılacaktır. 
    'Koşul: Hesap işlemleri .dll ile yapılcak.
    'Koşul: Bütün bilgiler veri tabanına kaydedilsin.
    'Koşul: Veri tabanındaki bilgiler button tıklamasıyla word dosyasına aktarılsın.
    Dim fis_count As Integer
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        fis_count = InputBox("Fiş sayısı girin")
        Dim fis_tarih(fis_count) As String
        Dim fis_konum(fis_count) As String
        Dim fis_miktar(fis_count) As Integer
        Dim fis_sum As Integer = 0
        Dim i As Integer
        For i = 1 To fis_count
            fis_tarih(i) = InputBox("Fiş tarihini girin")
            fis_konum(i) = InputBox("Fiş konumunu girin")
            fis_miktar(i) = CInt(InputBox("Fiş miktarını girin"))
            fis_sum += fis_miktar(i)
        Next
        Dim net_maas As Integer = CInt(InputBox("Kişinin net maaşını girin"))
        Dim sonuc_maas As Integer = net_maas * (fis_sum * 0.3)
        MessageBox.Show(sonuc_maas)
    End Sub

End Class

Hafta 8

dll_KitapKayit/Class1

Public Class Class1
    Function calc(ByVal price As Integer, ByVal count As Integer)

        Return price * count
    End Function

End Class

uygulama1

Public Class frm_main

    Private Sub frm_main_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim adet As Integer = CInt(InputBox("Kitap Adeti girin"))
        Dim kitap_ad() As String
        Dim kitap_yazar() As String
        Dim kitap_byil() As String
        Dim kitap_byer() As String
        Dim kitap_isban() As String
        Dim kitap_fiyat() As Integer
        Dim kitap_adeti() As Integer

        For i = 0 To adet
            kitap_ad(i) = InputBox("Kitap Adı")
            kitap_yazar(i) = InputBox("Kitap Yazar Adı")
            kitap_byil(i) = InputBox("Kitap Basım Yılı")
            kitap_byer(i) = InputBox("Kitap Basım Yeri")
            kitap_isban(i) = InputBox("Kitap ISBAN")
            kitap_fiyat(i) = CInt(InputBox("Kitap Fiyat"))
            kitap_adeti(i) = CInt(InputBox("Kitap Adeti"))
            Dim obj As New dll_KitapKayit.Class1()
            Dim result As Integer = obj.calc(kitap_fiyat(i), kitap_adeti(i))
            'database instert olacak.
        Next

    End Sub
End Class

uygulama2

Public Class frm_main

    Private Sub frm_main_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub
End Class

uygulama3

Public Class Form1

End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment