Rabu, 05 Februari 2014

TUTORIAL MEMBUAT PROGRAM FILE CONVERTER DI VB 2008

Yuhuuuuu…. Comeback again…
Dengan tutorial baru tentang VB aka Visual Basic …
Kali ini tutorialku tentang bagaimana membuat file converter dengan VB 2008… ^^
Yosh… Langsung aja ya….!!!!!!

Pertama siapkan bahannya ya… seperti yang ada dibawah ini…!!!

Toolbox
Text
Button 1
Browser
Button 2
Convert
Label 1
File Name  :
Label 2
Convert Into :
OpenFileDialog1
-
ComboBox1
-


Aku mendesignnya seperti ini !! ^^


Selanjutnya… pilih ComboBox1 > diProperties > Item


Next masukan file – file ini…
.AVI
.MP4
.MP3
.PNG
.GIF
.JPG
.PSD
.MPEG
.PDF
.txt
.exe





Nah jika sudah tinggal masukin deh… code2nya…
Code:
Button1:
OpenFileDialog1.ShowDialog()

Button2:
Dim type As String = ComboBox1.Text
If ComboBox1.Text = "" Then
MsgBox("No file type selected")
Else
If MsgBox(" Your File is being Converted into a " + type + " File") Then
Dim oldFile As String = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 4)
FileCopy(TextBox1.Text, oldFile + type)
End If
End If

OpenFileDialog1_FileOk:
Dim file As String = OpenFileDialog1.FileName
TextBox1.Text = file


Tampilannya seperti ini :

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        OpenFileDialog1.ShowDialog()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim type As String = ComboBox1.Text
        If ComboBox1.Text = "" Then
            MsgBox("No file type selected")
        Else
            If MsgBox(" Your File is being Converted into a " + type + " File") Then
                Dim oldFile As String = Mid(TextBox1.Text, 1, Len(TextBox1.Text) - 4)
                FileCopy(TextBox1.Text, oldFile + type)
            End If
        End If
    End Sub


    Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles OpenFileDialog1.FileOk
        Dim file As String = OpenFileDialog1.FileName
        TextBox1.Text = file
    End Sub
End Class




Hasil jadinya akan jadi seperti ini :) 






Yosh!!!!
 Selamat mencoba :) 

Tidak ada komentar:

Posting Komentar