24.2.11

Get Running Process

Hi Everybody,
I would like to discuss one of the most common FAQs regarding how we can point out running process with VB.NET 2010 Windows application? We can need to get information about running process which is related our main application.

If any question, please feel free and contact with me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.

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



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

'define a process
Dim ProcessRuning() As Process
Try

'get process name
ProcessRuning = Process.GetProcessesByName(TextBox1.Text)

'if the process is running
If ProcessRuning.Length > 0 Then

'give message
MsgBox("Process Running")

'if process is not running
Else

'give message
MsgBox("Process Not Running")
End If


Catch ex As Exception

'give message
MsgBox(ex.Message)

End Try



End Sub

4-) Lets run the application




5-) Lets close process(winword-outlook etc) and lets run application and see the result


Have a great day


Yener Turkeli
yenerturkeli@v-basic.net


16.2.11

Chart Control(Databinding)

Hi Everybody,
I would like to explain most common question within this essay , how we can use chart control and its databind properties with VB.NET 2010 windows application? If any question, please feel free and contact with me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.

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



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



3-) We are designing acces database and entering some datas





4-)We are writing this code

Imports System.Data
Imports System.Data.OleDb
Public Class Form1


Private Sub show_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles show_btn.Click

'Before delete series1
Chart1.Series.Clear()

'connection string
Dim my_connection As String = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\chart_data\customers.mdb"

'query string
Dim my_query As String = "SELECT customer_name, customer_bill FROM customer_information;"

'create a connection
Dim my_dbConnection As New OleDbConnection(my_connection)

'create a command
Dim my_Command As New OleDbCommand(my_query, my_dbConnection)

'open connection
my_Command.Connection.Open()

'create a reader and get data
Dim myReader As OleDbDataReader = my_Command.ExecuteReader(CommandBehavior.CloseConnection)

'bind data to chart
Chart1.DataBindTable(myReader, "customer_name")

'close reader
myReader.Close()

'close connection
my_dbConnection.Close()

End Sub
End Class

5-)Lets run application and click show chart button




Have a great day

Yener Turkeli
yenerturkeli@v-basic.net

1.2.11

Mp3 Header Read with VB.NET

Hi Everybody,
I would like to explain most common question within this essay , how we can read MP3 files header details with VB.NET 2010 windows application? If any question, please feel free and contact me y_turkeli@yahoo.com or yenerturkeli@v-basic.net.

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



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



3-)We are writing this code

Private Sub select_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles select_btn.Click
Dim open_file As New OpenFileDialog
open_file.Filter = "Files (*.mp3) *.mp3"

Try
If open_file.ShowDialog() = DialogResult.OK Then

file_txt.Text = open_file.FileName
Else
MsgBox("Please select a file", vbInformation, "Mp3 Reader")

End If
Catch ex As Exception
MsgBox(ex.Message, vbCritical, "Mp3 Reader")
End Try

End Sub

Private Sub read_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles read_btn.Click
Dim file_byte As Integer
Dim strTag As New String(" ", 3)
file_byte = FreeFile()
'Frame 0
Dim Title As New String(" ", 30)
' Frame 1
Dim Artist As New String(" ", 30)
'Frame 2
Dim Album As New String(" ", 30)

FileOpen(file_byte, file_txt.Text, OpenMode.Binary, _
OpenAccess.Read, OpenShare.Default)



FileGet(file_byte, strTag, LOF(file_byte) - 127, True)


Try



FileGet(file_byte, Title)
FileGet(file_byte, Artist)
FileGet(file_byte, Album)


MsgBox("This MP3 Album: " & Album, vbInformation, "VB.NET MP3 Reader")

MsgBox("This MP3 Title: " & Title, vbInformation, "VB.NET MP3 Reader")

MsgBox("This MP3 Artist: " & Artist, vbInformation, "VB.NET MP3 Reader")

Catch ex As Exception
MsgBox(ex.Message, "VB.NET MP3 Reader")
End Try


FileClose(file_byte)

End Sub

4-) Lets run application and select mp3 file



5-) Please click Read Button