El txt es horrible: B0035R 00167605753686811OFERTA LINEA DE30250000OFERTA LINEA DE CREDITO LUCAS 02013-03-05UG0005500000000CLP2048000000000000000000000000000000000000000000000000000001 5151000900000000000000000000000000000000000000000000000350035PILOTO PILOTO 2004-02-18.00.00.000000000 B0035R 00165531752686811OFERTA LINEA DE30357000OFERTA LINEA DE CREDITO LUCAS 02013-03-05UG0007500000000CLP2048000000000000000000000000000000000000000000000000000001 5151000900000000000000000000000000000000000000000000000350035PILOTO PILOTO 2004-02-18.00.00.000000000 B0035R 00163888025686886NOMINA AGIL 99050048NOMINA AGIL 02013-03-05UG0050000000000CLP2048000000000000000000000000000000000000000000000000000001 5101000900000000000000000000000000000000000000000000000350035PILOTO PILOTO 2004-02-18.00.00.000000000 esas son 3 lineas de 800 mas jaja, logre mostrar todo con:
Dim EST As String
Dim ENTRADA As Single
Dim PRODUCTO As String
Dim COD_PRODUCTO As String
Dim COD_SUBPRODUCTO As String
Dim CAMPAA As String
Dim VIGENCIA As String
Dim RUT As Integer
Dim DV As String
Dim IMPORTE As Long
If (TextBox1.Text <> "") Then
DataGridView1.Columns.Clear()
RESUMEN.Columns.Clear()
DataGridView1.Columns.Add("EST", "ESTADO")
DataGridView1.Columns.Add("ENTRADA",
"ENTRADA")
DataGridView1.Columns.Add("RUT", "RUT")
DataGridView1.Columns.Add("DV", "DV")
DataGridView1.Columns.Add("PRODUCTO",
"PRODUCTO")
DataGridView1.Columns.Add("COD_PRODUCTO",
"COD_PRODUCTO")
DataGridView1.Columns.Add("COD_SUBPRODUCTO",
"COD_SUBPRODUCTO")
DataGridView1.Columns.Add("CAMP",
"CAMPAA")
DataGridView1.Columns.Add("VIGENCIA",
"VIGENCIA")
DataGridView1.Columns.Add("IMPORTE",
"IMPORTE")
RESUMEN.Columns.Add("EST", "ESTADO")
RESUMEN.Columns.Add("CAMP", "CAMPAA")
Using leer As New
StreamReader(TextBox1.Text)
While Not
leer.EndOfStream()
Dim texto As String =
leer.ReadLine
EST = texto.Substring(0, 1)
ENTRADA = texto.Substring(1, 4)
PRODUCTO = texto.Substring(24, 15)
COD_PRODUCTO = texto.Substring(18, 2)
COD_SUBPRODUCTO = texto.Substring(20, 4)
CAMPAA = texto.Substring(47, 40)
VIGENCIA = texto.Substring(88, 10)
RUT = texto.Substring(8, 9)
DV = texto.Substring(17, 1)
IMPORTE = texto.Substring(101, 8)
DataGridView1.Rows.Add(EST, ENTRADA, RUT, DV, PRODUCTO,
COD_PRODUCTO, COD_SUBPRODUCTO, CAMPAA, VIGENCIA, Format(IMPORTE, "$
###,###,###.00"))
End While
End Using
ElseIf MsgBox("Debe Seleccionar Archivo", 0, "ERROR!!!") Then
End If
Pero lo que me falta y no e podido pillar es hacer un resumen tb en Datagridview para copiarlo o exportarlo a un Excel despues, la idea es que agrupe todos los campos iguales de CAMPAÑA y sume su IMPORTE respectivo, trate con incorporandole un IF entre el recorrido
If var(cont) <> CAMPAÑAThen
RESUMEN.Rows.Add(EST, CAMPAÑA)
var(cont) = CAMPAÑA
cont = cont + 1
End If
Pero el problema es que tira los campos aleatorio y no alfabeticamente por lo cual una campaña repetida puede estar al princio, al final o entremedio por lo cual se repetira. Es algo asi como GROUP BY de SQL server pero para Visual basic