Mostrando las entradas con la etiqueta captura. Mostrar todas las entradas
Mostrando las entradas con la etiqueta captura. Mostrar todas las entradas

jueves, 12 de septiembre de 2019

buscar dato en archivo

Private Sub btn_ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_ok.Click


        'Dim archivo() As String = File.ReadAllLines("")
        Dim archivo() As String = File.ReadAllLines("")

        Dim fila As Integer = tb_fila.Text.Trim
        Dim columna As Integer = tb_columna.Text.Trim
        Dim largo As Integer = tb_largo.Text.Trim


        Dim dato As String = ""


        'If fila > archivo.Length Then
        '    Exit Sub
        'End If


        For i As Integer = 0 To archivo.Length - 1
            If i = fila - 1 Then
                Dim linea() As Char = archivo(i)
                If linea.Length = 0 Then
                    MessageBox.Show("Línea vacía")
                    Exit Sub
                Else
                    For j As Integer = 0 To linea.Length - 1
                        If j = columna - 1 Then
                            'MessageBox.Show(linea(j))

                            Dim n As Integer = j + largo - 1
                            If n >= linea.Length Then
                                MessageBox.Show("No se puede obtener el dato")
                                Exit Sub
                            Else
                                For k As Integer = j To n
                                    dato += linea(k)
                                Next
                                MessageBox.Show(dato)
                                Return
                            End If
                        End If
                    Next
                End If
            End If
        Next

        Dim pause1 As String = ""

    End Sub