Results 1 to 10 of 10

Thread: ORDER A"file.txt" IN ALPHABETICAL ORDER

  1. #1

    Thread Starter
    New Member Gaspare's Avatar
    Join Date
    Sep 2013
    Posts
    6

    Exclamation 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 .

    PS = Please explain in the code you can use variable names that I put in here thanks

  2. #2
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    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.
    VB.NET MVP 2008 - Present

  3. #3

    Thread Starter
    New Member Gaspare's Avatar
    Join Date
    Sep 2013
    Posts
    6

    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

  4. #4
    Frenzied Member HanneSThEGreaT's Avatar
    Join Date
    Nov 2003
    Location
    Vereeniging, South Africa
    Posts
    1,492

    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....
    VB.NET MVP 2008 - Present

  5. #5

    Thread Starter
    New Member Gaspare's Avatar
    Join Date
    Sep 2013
    Posts
    6

    Re: ORDER A"file.txt" IN ALPHABETICAL ORDER

    ok then could you explain how to order a txt file in alphabetical order?

  6. #6
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    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.

  7. #7
    Addicted Member
    Join Date
    Oct 2008
    Location
    Califorina
    Posts
    235

    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.

  8. #8

    Thread Starter
    New Member Gaspare's Avatar
    Join Date
    Sep 2013
    Posts
    6

    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

  9. #9
    Fanatic Member
    Join Date
    Dec 2007
    Location
    West Yorkshire, UK
    Posts
    791

    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.

  10. #10
    Addicted Member
    Join Date
    Oct 2008
    Location
    Califorina
    Posts
    235

    Re: ORDER A"file.txt" IN ALPHABETICAL ORDER

    Quote Originally Posted by Gaspare View Post
    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?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width