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


23.11.11

Memory Management with VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can see memory 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 (memory_management)


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


3-) We are writing this code 

Imports System
Public Class Form1


    Private Sub show_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles show_btn.Click
        TotPhys_txt.Text = FormatNumber(My.Computer.Info.TotalPhysicalMemory, 0)
        TotVirt_txt.Text = FormatNumber(My.Computer.Info.TotalVirtualMemory, 0)
        avirt_txt.Text = FormatNumber(My.Computer.Info.AvailableVirtualMemory, 0)
    End Sub


End Class

4-) Lets run the application



Have a great day
Yener Turkeli
yenerturkeli@v-basic.net 


21.11.11

3D effect with VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can 3D effect 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 (3d_application)


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


3-) We are writing this code


    Dim i As Integer

    Private Sub Draw_3d(ByVal gr As Graphics, ByVal rect As Rectangle)


        Dim pr As Pen
        pr = New Pen(Color.Red)



        gr.DrawRectangle(pr, rect)

    End Sub


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

        i = i + 1

        Draw_3d(Me.CreateGraphics, New Rectangle(i, i, i + 50, i + 50))


    End Sub

4-) Lets run the application



Have a great day
Yener Turkeli
yenerturkeli@v-basic.net 


16.11.11

Convert .doc file to .html with VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can convert .doc to html 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 (using_word)


2-) Solution Explorer >> Add Referrence >> Select word component


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


4-) We are writing this code

Imports Microsoft.Office.Interop.Word
Public Class Form1
'create a word application
Dim word_ As New Application

'create a openfile dialog
Dim open_file As New OpenFileDialog

'create a word document
Dim word_doc As Document





Private Sub save_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_btn.Click
'define a save dialog
Dim save_file As New SaveFileDialog


'give its extension
save_file.Filter = "html files (*.html)|*.html"

'if ok click
If save_file.ShowDialog() = DialogResult.OK Then

'save as html
word_doc.SaveAs(save_file.FileName, Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatHTML)

'close
word_doc.Close(False)
End If
End Sub

Private Sub open_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles open_btn.Click
'give its filter
open_file.Filter = "Word Document (*.doc)|*.doc| Files (*.rtf)|*.rtf"

'if ok click at opendialog
If open_file.ShowDialog() = DialogResult.OK Then

word_doc = word_.Documents.Open(open_file.FileName, False)

End If
End Sub
End Class


5-) Lets run the application



6-) Open a word document from your PC


7-) Save word document as  .html 


8-) Lets check the html file which was saved


Have a great day
Yener Turkeli
yenerturkeli@v-basic.net 

1.11.11

Terminate Process via VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can terminate process 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 (terminate_process)


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


3-)We are writing this code

Imports System.Diagnostics
Public Class Form1
Private process_list As System.Diagnostics.Process
Private Sub show_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles show_btn.Click
ListBox1.Items.Clear()

For Each process_list In System.Diagnostics.Process.GetProcesses()
ListBox1.Items.Add(process_list.ProcessName & " : " & process_list.Id.ToString())
Next

End Sub

Private Sub terminate_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles terminate_btn.Click



For Each process_list In System.Diagnostics.Process.GetProcesses()


Dim process_name() As String = _
ListBox1.SelectedItem.ToString().Split(":")

Dim p_name As String = process_name(0).Trim()
Dim p_number As Integer = Convert.ToInt32(process_name(1).Trim())

If process_list.ProcessName = p_name And process_list.Id = p_number Then
process_list.Kill()
End If

Next
End Sub
End Class

4-) Lets run the application



5-) Select a process and click terminate button


Have a great day

31.10.11

Moving Bouncing Ball with VB.NET

Hi Everybody,

I would like to explain one of faq within this essay , how we can make a moving ball 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 (moving_ball)


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 Const MOV_BALL_W As Integer = 80
Private Const MOV_BALL_H As Integer = 80
Private x As Integer
Private y As Integer


Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
e.Graphics.Clear(Me.BackColor)
e.Graphics.FillEllipse(Brushes.Red, x, y, MOV_BALL_W, MOV_BALL_H)
e.Graphics.DrawEllipse(Pens.Black, x, y, MOV_BALL_W, MOV_BALL_H)
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim rnd As New Random
x = rnd.Next(Me.Width - 80)
y = rnd.Next(Me.Height - 80)
Me.Invalidate()
End Sub
End Class

4-) Lets run the application



5-) Resize the form size


Have a great day

Yener Turkeli
yenerturkeli@v-basic.net

17.10.11

Adobe Form Viewer with VB.NET

Hi Everybody,
I would like to explain one of faq within this essay , how we can can view PDF Form 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 (pdf)




2-) Select adobe component



3-) We need to see adobe component on toolbox




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



5-) We are writing this code

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

'create a openfile dialog
Dim open_file As New OpenFileDialog


'give its filter
open_file.Filter = "PDF files (*.pdf)|*.pdf| Adobe files (*.pdf)|*.pdf"


'if ok click at opendialog
If open_file.ShowDialog() = DialogResult.OK Then

Me.AxAcroPDF1.LoadFile(open_file.FileName)
End If



6-) Lets run the application


Have a great day

Yener Turkeli
yenerturkeli@v-basic.net


2.10.11

Flash Player with VB.NET

Hi Everybody,
I would like to explain one of faq within this essay , how we can can work Flash Player 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 (flash_player)




2-) Select flash component



3-)We need to see flash component on toolbox




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



5-) We are writing this code

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'create a openfile dialog
Dim open_file As New OpenFileDialog




'give its filter
open_file.Filter = "Flash files (*.swf)|*.swf| Flash files (*.swf)|*.swf"




'if ok click at opendialog
If open_file.ShowDialog() = DialogResult.OK Then

'load flash file
Me.AxShockwaveFlash1.LoadMovie(0, open_file.FileName)
End If

End Sub

6-) Lets run the application









Have a great day

Yener Turkeli
yenerturkeli@v-basic.net

29.8.11

Working with DataView

Hi Everybody,
I would like to explain one of faq within this essay , how we can can work DataView 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 (data_view)



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



3-) We are writing this code


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
'Create a DataTable
Dim my_datatable As New DataTable()

'dataview
Dim d_view As DataView = my_datatable.DefaultView


'Add an auto no column
my_datatable.Columns.Add("Customer_NO", GetType(Integer)) _
.AutoIncrement = True

'add column
my_datatable.Columns.Add("Name")
my_datatable.Columns.Add("Surname")


'add data
my_datatable.Rows.Add(Nothing, "Erica", "Teah")
my_datatable.Rows.Add(Nothing, "Soner", "Cinu")
my_datatable.Rows.Add(Nothing, "Namik", "Kemal")
my_datatable.Rows.Add(Nothing, "Jordan", "Islamov")
my_datatable.Rows.Add(Nothing, "Shane", "Boraci")

'set datasource
DataGridView1.DataSource = d_view

'give message
MsgBox("Excellent ", vbInformation, "Information")

Catch ex As Exception

'give message
MsgBox(ex.Message, vbCritical, "Information")

End Try


End Sub

4-) Lets run application and click button



Have a great day

Yener Turkeli
yenerturkeli@v-basic.net