Hi! I have the following code to read a FlexGrid and save the data in a txtFile. I want to introduce a break line each 12 parameters written that are separated by " ; ".
My code:
What it shows in the file:Code:Private Sub Save_Data_Click() Dim ret As Boolean ' Le envia el control MsFlexgrid, el path del archivo txt y el delimitador ret = Export_Data(Grid1, "C:\Documents and Settings\Administrador\Escritorio\TFG\Registros\Register_Data.txt", Chr(59)) If ret Then MsgBox "Table exported! ", vbInformation End If End Sub Public Function Export_Data(MSFlexGrid As Object, Path_Txt As String, Delimitador As Variant) As Boolean On Error GoTo Funcion_Error Dim i, ja As Integer Dim Free_File As Integer ' Número de archivo libre para crear el archivo de texto Free_File = FreeFile ' Abre y crea el archivo Open Path_Txt For Output As #Free_File Print #Free_File, "#MAC; RbRx; RbTx; PKTs; Tact; LastAct; RSSI; SNR; CCQtx; Throughput; IP; Mod#" ' Recorre las filas del Flexgrid For i = 1 To Grid1.Rows - 1 Grid1.Row = Fi 'Empiezo en la fila 1 no en la cero For j = 1 To Grid1.Cols - 1 Grid1.Col = j ' Write the data 'Print #Free_File, vbNullString & Grid1.text & vbNullString; If j >= 1 Then Print #Free_File, Grid1.text & Delimitador; End If Next 'Print #Free_File, "" Next Close Exportar_Datos = True ' Fin Exit Function ' error Funcion_Error: Close #Free_File MsgBox Err.Description, vbCritical End Function
And I want:Code:#MAC; RbRx; RbTx; PKTs; Tact; LastAct; RSSI; SNR; CCQtx; Throughput; IP; Mod# (1sr line) ;B8:64:91:68:1C:50;65Mbps-20MHz/1S;65Mbps-20MHz/1S;1131,1109;26m4s;210ms;-62@1Mbps;25 (2nd line) dB;99%;60958;192.168.100.253;CCK:1-11;;B8:64:91:68:1C:50;65Mbps-20MHz/1S;65Mbps- (2nd line) 20MHz/1S;1207,1185;27m10s;440ms;-32@6Mbps;55 dB;96%;60488;192.168.100.253;CCK:1- (2nd line) 11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (2nd line)
The ;;;;;;;;;;;;;;;; are blank cells. It would be a great idea delate it too....Code:#MAC; RbRx; RbTx; PKTs; Tact; LastAct; RSSI; SNR; CCQtx; Throughput; IP; Mod# (1sr line) ;B8:64:91:68:1C:50;65Mbps-20MHz/1S;65Mbps-20MHz/1S;1131,1109;26m4s;210ms;-62@1Mbps;25 (2nd line) dB;99%;60958;192.168.100.253;CCK:1-11; (2nd line) ;B8:64:91:68:1C:50;65Mbps-20MHz/1S;65Mbps- (3rd line) 20MHz/1S;1207,1185;27m10s;440ms;-32@6Mbps;55 dB;96%;60488;192.168.100.253;CCK:1- (3rd line) 11;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (3rd line)
Thank you!




Reply With Quote
