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