terça-feira, 19 de julho de 2011

on



Imports System.IO
Imports System.IO.File

Public Class Form1
    Private Sub Button_salvar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_salvar.Click
        Me.SaveFileDialog1.ShowDialog()
        If Me.SaveFileDialog1.FileName = "" Then
            Exit Sub
        End If
        Dim caminho As String = Me.SaveFileDialog1.FileName
        Try
            Dim strm As New StreamWriter(caminho)
            Try
                strm.WriteLine("Nome: " & Me.txtnome.Text)
                strm.WriteLine("Endereço: " & Me.txtendereco.Text)
                strm.WriteLine("Telefone: " & Me.mtxttelefone.Text)
                strm.WriteLine("Comentário: " & Me.txtcomentario.Text)
                MsgBox("Dados gerados com sucesso", MsgBoxStyle.Information, "OK")
            Finally
                strm.Close()
            End Try
        Catch ex As Exception
            MessageBox.Show("Erro ao tentar salvar", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_limpar.Click
        Me.txtnome.Clear()
        Me.txtendereco.Clear()
        Me.mtxttelefone.Clear()
        Me.txtcomentario.Clear()
        Me.txtnome.Focus()
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button_fechar.Click
        End
    End Sub
End Class

Espero ter ajudado e até a próxima...

 

0 comentários:

Postar um comentário