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

Imports Public Class Private Sub Byval As Byval As End Sub

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)
26 views2 pages

Imports Public Class Private Sub Byval As Byval As End Sub

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
You are on page 1/ 2

Imports System.

IO
Public Class Form1
Private Sub SaveFileDialog1_FileOk(ByVal sender As System.Object,
ByVal e As System.ComponentModel.CancelEventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim strfilename As String
With OpenFileDialog1
.Filter = "textfile(*.txt)(*.txt)|all files(*.*)*.**"
.FilterIndex = 1
.InitialDirectory = "c:\"
.Title = " openfiledialog"
End With
If OpenFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK
Then
strfilename = OpenFileDialog1.FileName
Dim objreader As StreamWriter = New
StreamWriter(strfilename, False)
objreader.Write("textfile.text")
objreader.Close()
objreader = Nothing
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Close()
End Sub
EndClass

You might also like