Ver Mensaje Individual
  #3 (permalink)  
Antiguo 08/09/2008, 15:06
Avatar de moradazo
moradazo
 
Fecha de Ingreso: julio-2008
Ubicación: [email protected]
Mensajes: 355
Antigüedad: 18 años, 2 meses
Puntos: 2
Respuesta: Como pasar a la siguiente linea de un archivo plano (txt)

Este codigo me lo brindo Avellaneda:

Código PHP:
Private Sub funcion()
        
Dim ip As IntPtr = Runtime.InteropServices.Marshal.AllocHGlobal(100000)
        
Dim sb As New System.Text.StringBuilder(100000)
        
Dim bt As Integer = GetPrivateProfileSection("Nombre", ip, 100000, "C:/tu_archivo.txt")
        Try
            For 
i As Integer = 0 To bt - 1
                sb
.Append(Convert.ToChar(Runtime.InteropServices.Marshal.ReadByte(ip, i)))
            
Next
            sb
.Remove(sb.Length - 1, 1)
            For 
Each line As String In sb.ToString().Split(Convert.ToChar(0))
                
Dim iPos As Integer = InStr(line, ",") - 1
                text1
.Text = Microsoft.VisualBasic.Right(line, Len(line) - iPos)
                
text2.Text = Microsoft.VisualBasic.Right(line, Len(line) - iPos + 1)
                
text3.Text = Microsoft.VisualBasic.Right(line, Len(line) - iPos + 2)
                
text4.Text = Microsoft.VisualBasic.Right(line, Len(line) - iPos + 3)
            
Next
        
Catch ex As System.Exception
            System
.Windows.Forms.MessageBox.Show(ex.Message)
        
Finally
            Runtime
.InteropServices.Marshal.FreeHGlobal(ip)
        
End Try
        
FileClose(0)
    
End Sub 
Tu archivo de texto debes tener un encabezado entre corchetes, en este caso asi [Nombre] como aparece arriba en el GetPrivateProfileSection que es el que leerá el archivo de texto.

Espero te sirva.