Visual Basic.NET - DESPLAZAMIENTO CON STREAMREADER

 
Vista:

DESPLAZAMIENTO CON STREAMREADER

Publicado por carlos velazco (2 intervenciones) el 26/10/2007 17:40:14
HOLA ESPERO QUE ALGUINE ME PUEDA AYUDAR, TENGO UNA APLICACION EN VB NET 2003 Y ME HAN PEDIDO UN FORMULARIO DE MANTENIMIENTO DONDE SE ALMACENEN LOS DATOS EN UN ARCHIVO .TXT , TENGO YA LA MAYYORIA DE LOS BOTONES COMO GUARDAR, MODIFICAR, ELIMINAR PRIMER REGSITRO Y ULTIMO REGISTRO, MI PROBLEMA ES EL SIGUIENTE :

ME FALTA LOS BOTONES SIGUIENTE Y ANTERIOR: TENGO ESTE CODIGO NO SE SI ALGUIEN ME PUDIERA AYUDAR AL RESPECTO:

ESTE CODIGO ES DEL BOTON SIGUIENTE PERO ME FALTA ALGO POR QUE NO ME }
FUNCIONA
Dim sr As New StreamReader("c:\producto.txt")
posicion = posicion + 1
For i = 0 To sr.Peek
Dim arreglo() As String
arreglo = Split(sr.ReadLine, ",")
posicion = posicion + 1
If posicion >= contador Then
MsgBox("posicion" & " " & posicion)
'MsgBox("contador" & " " & contador)
MsgBox(arreglo(0))
contador += 1
'Exit Sub
Else
MsgBox("llegastes al final")
End If
Next i
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:DESPLAZAMIENTO CON STREAMREADER

Publicado por Harold V. (411 intervenciones) el 27/10/2007 04:40:06
Hola:

Aqui te envio este pequeño ejemplo, espero te ayude.
Notaras que HybridDic empieza desde 1 asi que el valor 0 esta siempre vacio
esto es para darle valores con los q trabajamos normalmente a partir de 1 y
no 0.

Imports System.IO
Imports System.Collections.Specialized

Public Class Form2

Dim posicion As Int32 = 0
Dim numreg As Int32
Dim hybridDic As New HybridDictionary
Dim arreglo() As String

Private Sub btnAnterior_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnterior.Click

If posicion >= 1 Then
posicion = posicion - 1
If hybridDic.Contains(posicion) Then
arreglo = Split(hybridDic.Item(posicion), ",")
MsgBox("posicion" & " " & posicion & " " & arreglo(0))
Else
MsgBox("llegastes al principio")
End If
ElseIf posicion <= 0 Then
MsgBox("llegastes al principio")
End If

End Sub

Private Sub btnSguiente_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSiguiente.Click
If posicion >= 0 And posicion < numreg Then
posicion = posicion + 1
arreglo = Split(hybridDic.Item(posicion), ",")
MsgBox("posicion" & " " & posicion & " " & arreglo(0))
ElseIf posicion = numreg Then
MsgBox("llegastes al final")
End If
End Sub

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim sr As New StreamReader("c:\Sample.txt")
While Not sr.EndOfStream
numreg += 1
hybridDic.Add(numreg, sr.ReadLine)
End While
sr.Close()
End Sub

End Class
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar