0% found this document useful (0 votes)
9 views2 pages

VB.NET File Dialog Example Code

This code defines a form class with two buttons. Button1 uses an OpenFileDialog to select a file, then writes the text "textfile.text" to that file using a StreamWriter. Button2 closes the form when clicked.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

VB.NET File Dialog Example Code

This code defines a form class with two buttons. Button1 uses an OpenFileDialog to select a file, then writes the text "textfile.text" to that file using a StreamWriter. Button2 closes the form when clicked.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

Imports System.

IO
Public Class Form1
Private Sub SaveFileDialog1_FileOk(ByVal sender As [Link],
ByVal e As [Link])
End Sub
Private Sub Button1_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Dim strfilename As String
With OpenFileDialog1
.Filter = "textfile(*.txt)(*.txt)|all files(*.*)*.**"
.FilterIndex = 1
.InitialDirectory = "c:\"
.Title = " openfiledialog"
End With
If [Link]() = [Link]
Then
strfilename = [Link]
Dim objreader As StreamWriter = New
StreamWriter(strfilename, False)
[Link]("[Link]")
[Link]()
objreader = Nothing
End If
End Sub
Private Sub Button2_Click(ByVal sender As [Link], ByVal e As
[Link]) Handles [Link]
Close()
End Sub
EndClass

You might also like