17.12.11

Update Database via Dataset

Hi Everybody,


I would like to explain one of faq within this essay , how we can update database via dataset ? If any question, please feel free to contact me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.





1-) We are going to use this access database (c:\microsoft\customer.mdb)


2-) We are creating a new Windows Application Project (dataset_update)


3-)  We are designing this windows form in a similar way to the picture below

4-) We are writing this code

Imports System.Data.OleDb
Public Class Form1

    Dim my_dbConnection As New OleDbConnection


    Dim my_Command As New OleDbCommand



    Dim my_adapter As New OleDbDataAdapter(my_Command)


    Dim my_dataset As New DataSet("Customers")

    Private Sub show_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles show_btn.Click
        my_dbConnection.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\microsoft\customer.mdb"



        my_Command.CommandText = "select * from customer "


        my_Command.Connection = my_dbConnection


        my_adapter.Fill(my_dataset)


        customer_grid.DataSource = my_dataset.Tables(0)
    End Sub

    Private Sub update_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles update_btn.Click
        Dim my_builder As OleDbCommandBuilder = _
            New OleDbCommandBuilder(my_adapter)
        my_builder.GetUpdateCommand()
        my_adapter.Update(my_dataset)

    End Sub
End Class

5-) Click Show Data button and modify some data.



6-) Lets check database table again.


Have a great day

Yener Turkeli


5.12.11

Working With Color Matrix

Hi Everybody,



I would like to explain one of faq within this essay , how we can work color matrix class with VB.NET windows application ? If any question, please feel free to contact me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.


Several methods of the ImageAttributes class adjust image colors by using a color matrix.

1-) We are creating a new Windows Application Project (color_matrix)






2-) We are designing this windows form in a similar way to the picture below






3-)We are writing this code



Imports System.Drawing.Imaging
Public Class Form1









Private Sub PictureBox2_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox2.Paint
Dim my_image = PictureBox1.Image
Dim atrb As New ImageAttributes()
Dim wdt As Integer = my_image.Width
Dim hght As Integer = my_image.Height




Dim color_matrix As Single()() = { _
New Single() {HScrollBar1.Value, 0, 0, 0, 0}, _
New Single() {0, HScrollBar1.Value, 0, 0, 0}, _
New Single() {0, 0, HScrollBar1.Value, 0, 0}, _
New Single() {0, 0, 0, HScrollBar1.Value, 0}, _
New Single() {0, 0, 0, 0, 1}}



Dim colorMatrix As New ColorMatrix(color_matrix)



atrb.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap)




e.Graphics.DrawImage(my_image, _
New Rectangle(0, 0, wdt, hght), _
0, 0, wdt, hght, GraphicsUnit.Pixel, atrb)




End Sub



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



4-)Lets run the application





5-) Change scrollbar position.



Have a great day
Yener Turkeli



1.12.11

Get Scren Shot with VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can get screenshot with VB.NET windows application ? If any question, please feel free to contact me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.

1-) We are creating a new Windows Application Project (screen_shot)


2-) We are designing this windows form in a similar way to the picture below

3-)We are writing this code

Imports System.Drawing.Imaging

Public Class Form1


Private screen_image As Bitmap
Private Screen_shot As Graphics

Sub get_screen()

screen_image = New Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb)

Screen_shot = Graphics.FromImage(screen_image)

Screen_shot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy)



Me.PictureBox1.Image = screen_image

End Sub



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

get_screen()
End Sub


Private Sub stp_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles stp_btn.Click
Timer1.Enabled = False
End Sub

Private Sub str_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles str_btn.Click
Timer1.Enabled = True
End Sub
End Class


4-) Lets run the application


Create ZIP File With VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can create ZIP file with VB.NET windows application ? If any question, please feel free to contact me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.

1-) We are creating a new Windows Application Project (zip_file)


2-) We are designing this windows form in a similar way to the picture below


3-) We are writing this code

Public Class Form1


Private Sub zip_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles zip_btn.Click
Dim my_process As System.Diagnostics.Process = New System.Diagnostics.Process()
Dim file_name As String

Dim file_open As New OpenFileDialog
If file_open.ShowDialog = Windows.Forms.DialogResult.OK Then

file_name = file_open.FileName

End If

my_process.StartInfo.FileName = ("C:\Program Files\WinRAR\rar.exe")
my_process.StartInfo.Arguments = (" a -ms*.rar;*.zip;*.png;*.doc " & "C:\zip_files\test.rar " & file_name)
my_process.Start()
my_process.WaitForExit()
End Sub
End Class

4-) Lets run the application



Have a great day

Yener Turkeli