Imports System.IO
Public Class Form1
Dim a As StreamWriter
Private Sub TxtContenido_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtContenido.TextChanged
Dim con As Integer = 0
Dim Cadena As String = TxtContenido.Text()
For i = 1 To Len(Cadena)
If Mid(Cadena, i, 1) = Chr(13) Then 'Si una cadena = un Retorno de carro , Entonces
con = con + 1 'Cuenta una Linea
End If
Next
lblcontar.Text = CStr(con)
End Sub
Private Sub Guardar_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Guardar.Click
'If Len(Trim$(TxtContenido.Text)) = 0 Then
'MsgBox("no hay nada escrito")
'End If
If MsgBox("REVISAR ANTES DE GUARDAR", vbYesNo) = vbYes Then
If File.Exists("Platform\Inventario\" & Me.ComboBox1.Text & " " & Me.ComboBox2.Text & " " & lblcontar.Text & Punto.Text & ".txt") = False Then
'Crear ruta y titulo del archivo a crear
a = File.CreateText("Platform\Inventario\" & Me.ComboBox1.Text & " " & Me.ComboBox2.Text & " " & lblcontar.Text & Punto.Text & ".txt")
'guardar lo que contiene en el texbox1
a.Write(Me.TxtContenido.Text)
'cerrar la variable para no escribir sobre ella
a.Close()
'que nos vacie la varible
a = Nothing
TxtContenido.Text = ""
Punto.Text = ""
ComboBox1.Text = ""
Else : MsgBox("PONER UNA LETRA", 16, "EL ARCHIVO YA EXISTE")
End If
End If
TxtContenido.Focus()
End Sub
Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
Dim Salir As Object
Salir = MsgBox("CLIC EN NO PARA CORREGIR", 4, "CUIDADO VA CERRAR")
If Salir = DialogResult.No Then
e.Cancel = True
End If
End Sub
End Class