ORDER A"file.txt" IN ALPHABETICAL ORDER
I apologize in advance for the bad translation
HELLO BOYS ARE NEW IN THE FORUM
I AM TRYING TO MAKE A PLAN FOR THE MANAGEMENT OF PERSONAL DATA AND SINCE THE FIRST ARE WEAPONS STO FILE.TXT INSTEAD OF USING THE DATABASE SQL
MY PROBLEM IS WHEN ORDERING AN FILE.TXT WHERE THERE ARE CARICATTI The Structured DATA OF A PERSON IN THIS WAY:
Public Structure Cliente
<VBFixedString(4)> Dim ID As Integer
<VBFixedString(6)> Dim Importo As String
<VBFixedString(30)> Dim Nome As String
<VBFixedString(30)> Dim Cognome As String
Dim Born As Date
<VBFixedString(30)> Dim Location As String
<VBFixedString(30)> Dim Province As String
<VBFixedString(16)> Dim CodFisc As String
<VBFixedString(30)> Dim Indirizzo As String
<VBFixedString(30)> Dim Provincia As String
<VBFixedString(5)> Dim CAP As String
<VBFixedString(30)> Dim Citta As String
<VBFixedString(2)> Dim Maggiorenne As String
<VBFixedString(30)> Dim Genitore As String
<VBFixedString(7)> Dim Abbonamento As String
<VBFixedString(19)> Dim Attivita As String
Dim Inizio As Date
Dim Termine As Date
<VBFixedString(30)> Dim Email As String
<VBFixedString(15)> Dim Cell As String
<VBFixedString(1000)> Dim Note As String
End Structure
Public Persona as Cliente
NOW I WANT TO ORDER IN ALPHABETICAL ORDER YOUR DETAILS IN THIS FILE CREATED IN THIS WAY
Sub Aprifile()
numFile = FreeFile()
FileOpen(Numfile, "Clienti.txt", OpenMode.Random, OpenAccess.ReadWrite, , Len(Persona))
End Sub
CAN YOU PLEASE HELP ME WITH A CODE THAT ARE TOO HEAVY AS THE METHOD "quicksort" I CAN NOT UNDERSTAND HOW TO USE :confused:.
PS = Please explain in the code you can use variable names that I put in here thanks :)
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
My ears, my ears, my ears. Luckily I am 50% deaf in one ear....
Anyways, this can be helpful :
http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
As I would suggest you read your file differently and not with FileOpen.
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
thanks for your reply but unfortunately does not meet my request for help. If possible I would like that you wrote to me a piece of code that makes me sort my files in alphabetical order thanks :)
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
Problem is: I'm not here to write code, I'm here to help you fish. That is how I know what I know. Hopefully someone else will write your code for you.... :eek:
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
ok then could you explain how to order a txt file in alphabetical order?
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
read it into an array and sort the array.OrderBy
Look at this link.
This gives different ways to do it (with code) and also shows how to order by a particular field in the structure.
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
Where is the data coming from and where is it going? If it's coming from a database, order the data before the export.
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
no data are loaded directly from a file.txt still are not able to communicate with the access database VB2005
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
Code:
Imports System.IO
...
Dim ReadLines() as Cliente = File.ReadAllLines(PathToFileOnDisk) 'PathToFileOnDisk is a string with the absolute path name to the .txt file
ReadLines= ReadLines.OrderBy(Function(c) c.NOME)
File.WriteAllLines (PathToFileOnDisk, ReadLines)
This is free typed and NOT TESTED but it should do what you are wanting. It will order the records by the field "NOME" in the structure.
This is not to be copied and pasted but is a guide to what you need to do.
Re: ORDER A"file.txt" IN ALPHABETICAL ORDER
Quote:
Originally Posted by
Gaspare
no data are loaded directly from a file.txt still are not able to communicate with the access database VB2005
I mean't before it becomes the text file where is the data coming from? Does it come from a program's output? exported for a database?