Extension File Converter in VB.NET

This tutorial provides to make a program that can convert a file into any any file that is changing the extension filename of this file using vb.net. Now, let's start this tutorial! 1. Let's start with creating a Windows Form Application for this tutorial by following the following steps in Microsoft Visual Studio: Go to File, click New Project, and choose Windows Application. 2. Next, add two Buttons named Button1 and labeled it as "Browse File.." for browsing and searching any types of file and Button2 named "Convert" for converting this file to the desired extension file. Insert one TextBox named TextBox1 for displaying the filepath and filename, and a ComboBox named ComboBox1 to have a list of extension file. You must design your interface like this: design 3. Put this code below in your Form_Load.
  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2. ComboBox1.Items.Add(".doc")
  3. ComboBox1.Items.Add(".txt")
  4. ComboBox1.Items.Add(".jpeg")
  5. ComboBox1.Items.Add(".mp4")
  6. ComboBox1.Items.Add(".mp3")
  7. ComboBox1.Items.Add(".jpg")
  8. ComboBox1.Items.Add(".gif")
  9. ComboBox1.Items.Add(".docx")
  10. ComboBox1.Items.Add(".rtf")
  11. End Sub
The code above loads item in the ComboBox when loading the form. These are the extension files as option for conversion such as doc,txt,jpeg,mp4,mp3,jpg,gif,docx, and rtf file. 4. For Button1_Click which is used for browsing a certain file, put this code below.
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Dim browse As New OpenFileDialog
  3. If browse.ShowDialog = DialogResult.OK Then
  4. TextBox1.Text = browse.FileName
  5. End If
The code above tells to open a file dialog to browse a certain file. After choosing and selecting this certain file, this will then display the filename and path to the textbox. 5. For Button2_Click which is used for changing the extension file of the selected filename, put this code below.
  1. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  2. Dim extensionFile As String = ComboBox1.Text
  3. MsgBox(TextBox1.Text + " is changed into a " + extensionFile + " file.")
  4. Dim oldFile As String = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 4)
  5. FileCopy(TextBox1.Text, oldFile + extensionFile)
  6. End Sub
We used variable extensionFile As String that will hold the value of our ComboBox1 (the extension files). Then it will prompt the user the filename is changed into a selected extension file type. The Mid Function in our oldFile variable will return a string containing a specified number of characters from the textbox and the length of the file on this control. Then, the FileCopy function was established to copy a file, TextBox1 as the source, and the newfile will be the same filename but with different extension file now.

Output:

output For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISware

Comments

Submitted bydonbermoyon Tue, 04/29/2014 - 16:05

Thank you for the appreciation! :) Best Regards, Engr. Lyndon R. Bermoy IT Instructor/System Developer/Android Developer Mobile: 09102918563 Telephone: 826-9296 E-mail:[email protected]

Add new comment