Semoga bisa bermanfaat,

Salam,


Vavai

HowTo: Let the user pick multiple files in VB .NET

Link : 
http://www.vb-helper.com/howto_net_pick_multiple_files.html
Sample : 
http://www.vb-helper.com/HowTo/howto_net_pick_multiple_files.zip

When a program lets the user pick more than one file, there's always a
question about how to handle the current directory. Should the program
update the current directory each time the user picks a file? Should
different file selections have separate current directories? For
example, if you're loading a file, transforming it, and saving it in a
new file, should the program track separate directories for the old and
new files?

The program lets the user load several files and keeps track of the
directories for each. It also keeps track of the file selection dialog
filter the user picks for each.

When the program starts, it initializes arrays containing references to
its TextBox and Button controls. It then loads the previously saved file
names and the dialog filter numbers used the last time.

Private m_FilterSelected(MAX_CTL) As Integer

Private m_txtFile(MAX_CTL) As TextBox
Private m_btnBrowse(MAX_CTL) As Button

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
    ' Make arrays referencing the TextBoxes and Buttons.
    m_txtFile(0) = txtFile0
    m_txtFile(1) = txtFile1
    m_txtFile(2) = txtFile2
    m_txtFile(3) = txtFile3

    m_btnBrowse(0) = btnBrowse0
    m_btnBrowse(1) = btnBrowse1
    m_btnBrowse(2) = btnBrowse2
    m_btnBrowse(3) = btnBrowse3

    ' Load previously saved file names and filter indices.
    For i As Integer = 0 To MAX_CTL
        m_txtFile(i).Text = GetSetting(APP_NAME, "Files", "File" & i,
"")
        m_FilterSelected(i) = Integer.Parse(GetSetting(APP_NAME,
"Files", "Filter" & i, "0"))
    Next i
End Sub

When the program ends, the Unload event handler saves the current file
names and the most recently used file filter numbers for each file.

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    For i As Integer = 0 To MAX_CTL
        SaveSetting(APP_NAME, "Files", "File" & i, m_txtFile(i).Text)
        SaveSetting(APP_NAME, "Files", "Filter" & i,
m_FilterSelected(i).ToString)
    Next i
End Sub

When the user clicks one of the form's browse buttons, the program gets
the index of the button pressed from its Tag property (set at design
time). It prepares the File Open dialog, sets its file name to the
corresponding TextBox's current value, and displays the dialog. If the
user clicks OK, the program saves the selected file name and the
dialog's current filter number for use next time.


    If dlgFile.ShowDialog() = DialogResult.OK Then
        m_txtFile(index).Text = dlgFile.FileName
        m_FilterSelected(index) = dlgFile.FilterIndex
    End If
End Sub




------------------------ Yahoo! Groups Sponsor --------------------~--> 
<font face=arial size=-1><a 
href="http://us.ard.yahoo.com/SIG=12h3calec/M=362329.6886308.7839368.1510227/D=groups/S=1705115364:TM/Y=YAHOO/EXP=1123642882/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
--------------------------------------------------------------------~-> 

Untuk keluar dari millis ini, kirim email kosong ke:
[EMAIL PROTECTED]

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/Programmer-VB/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Kirim email ke