Results 1 to 35 of 35

Thread: [RESOLVED] txt files (writing to and retrieving from)

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Resolved [RESOLVED] txt files (writing to and retrieving from)

    Ok. I have searched the forums a few times and havent found anything that assists me with my question.

    I am going to be adding a tab to my SSTab whereby it has two input fields and one button.

    lets just say the input fields are called InputField1.text and InputField2.text

    What I would like to do is when you enter something into both input fields and click on the form button, it saves those values to a text file in the format of:

    InputField1.value, InputField2.value

    Then, when someone enters a value into one of the input fields within one of the other tabs, it searchs for the word in either column, and then shows its counterpart in a labal caption.

    How would this be done?
    Last edited by BrailleSchool; May 7th, 2005 at 01:46 AM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    If you use a db for the dictionary, you could run a query to search any field, depending on which tab the textbox is filled in from. You could also have definitions in each language in the same record.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    If you use a db for the dictionary, you could run a query to search any field, depending on which tab the textbox is filled in from. You could also have definitions in each language in the same record.
    I currently have many of the records in a MySQL database, the only thing is, when I distribute the VB6 app, they would have to specify a connection param to the DB. I was thinking of having it access the txt file to get the records and then displaying them. Also giving the ability to add additional words.

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Well reading a large text file is a slow process. I also think you should use a database. You could use an Access database so you only need to distribute the mdb file, the user doesn't have to have Access installed.

  5. #5
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    If they are single words, I guess you could use a two-dimensional array. You may want to look at using a collection, also, as you could use a UDT that contained both definitions, except there would only be one key.

  6. #6

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by Joacim Andersson
    Well reading a large text file is a slow process. I also think you should use a database. You could use an Access database so you only need to distribute the mdb file, the user doesn't have to have Access installed.
    If it was to be a text file, it would have something like 14,000 lines in the format of

    value,value

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    If they are single words, I guess you could use a two-dimensional array. You may want to look at using a collection, also, as you could use a UDT that contained both definitions, except there would only be one key.
    example:

    tab 0

    if you inputted into txtEnglish.text the following word:
    chuckle

    then the caption for lblIrish would be déan maolgháire

    and the line in the txt file would be

    chuckle, déan maolgháire

    tab 1

    if you inputted déan maolgháire into txtIrish.text then the caption for
    lblEnglish would be chuckle (from same text file.)

  8. #8
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    If it was to be a text file, it would have something like 14,000 lines in the format of

    value,value
    Think how much time it would take to read each line every time you want to look up a word. Of course you could read it in only once but that would mean you would store two arrays containing 14,000 records each in memory which is a waste. Use a database instead, since this is a desktop application an Access database would be perfect.

  9. #9
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    I agree. Use ADO to connect to a DB and you will be able to search either field very quickly, as well as include other fields in the same record.

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by Joacim Andersson
    Think how much time it would take to read each line every time you want to look up a word. Of course you could read it in only once but that would mean you would store two arrays containing 14,000 records each in memory which is a waste. Use a database instead, since this is a desktop application an Access database would be perfect.
    i have no experience with Access.

  11. #11

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    I agree. Use ADO to connect to a DB and you will be able to search either field very quickly, as well as include other fields in the same record.
    the current program uses ADO, and I have the connection string within the app and in the third input box on the ado control. having said that, each person who gets the app would have to configure the database connection which is not a good thing.

  12. #12
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    i have no experience with Access.
    Do you know how to use ADO? Converting the MySQL db into an Access db should not cause any problem. It sounds as if you only need one very simple table.

  13. #13
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    All users can use the same connection string with ADO, so they'd be able to open the db as long as it was installed in the correct/expected location on their machine.

  14. #14
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    the current program uses ADO, and I have the connection string within the app and in the third input box on the ado control. having said that, each person who gets the app would have to configure the database connection which is not a good thing.
    No, they don't have to do that if you're using a simple Access database. Since you can put that in the same folder as the application. The connection string would look simular to this:
    VB Code:
    1. sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\theMDBFile.mdb;"

  15. #15

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    All users can use the same connection string with ADO, so they'd be able to open the db as long as it was installed in the correct/expected location on their machine.
    the mysql db is located on my server that is located in FL so they would have to have WWW access to be able to get to the db.

    I am trying to think of ways that would be more convenient for the user(s)

    theMDBFile.mdb being the db?

  16. #16
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    theMDBFile.mdb being the db?
    Yes, you would probably want to call it something else Dictionary.mdb perhaps?

  17. #17
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    Wouldn't you want a local version using the mdb as well as a version that runs on the Internet? You could evn have no program necessary to run off the Internet.

  18. #18

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    Wouldn't you want a local version using the mdb as well as a version that runs on the Internet? You could evn have no program necessary to run off the Internet.
    Preferably the program would have some kind of db that you didnt have to have www access to be able to use (use online or offline)

    with as little or no user configuration as possible

    What I would love is:
    1) user downloads the program
    2) double clicks the icon to execute
    3) automatically use

    if there are updates to the dictionary file (db or what ever) then i can always use some kind of auto update program to update the words list (there is a prog that does this in the code bank)
    Last edited by BrailleSchool; May 3rd, 2005 at 07:59 PM.

  19. #19
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    Maybe the web version would have updates, but you should also be able to dowbload updates that get inserted into the local db. You could use sql to insert, delete, or change the db. I see no reason to need the web mysql db, though.

  20. #20

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    Maybe the web version would have updates, but you should also be able to dowbload updates that get inserted into the local db. You could use sql to insert, delete, or change the db. I see no reason to need the web mysql db, though.
    I am just thinking for the convenience of use for a user. The user also not knowing the access credentials to a database.

    If you used an access database on a local machine (127.0.0.1) then would they have to install anything on their machine to be able to access and use the database format or is the mdb file good enough?

  21. #21
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    You would only need the MDB file, and for an Access database you don't specify an IP address you simply specify the local path to the MDB file. Access is not a RDBMS system.

  22. #22

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by Joacim Andersson
    You would only need the MDB file, and for an Access database you don't specify an IP address you simply specify the local path to the MDB file. Access is not a RDBMS system.
    so a path would be something like C:\Program Files\Translator\Dictionary.mdb?

    Does Microsoft Access have anything to do with the creation of the MDB files? (The Access that comes with MS Office?)

  23. #23
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    You can create the same thing with Office Access, or using ADO. You can create it with Access, and then read it with VB.

  24. #24
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    If you like I can help you convert the MySQL data into an Access database. I only need to know the layout of the table and the connection string you would use for the MySql database.

  25. #25

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    You can create the same thing with Office Access, or using ADO. You can create it with Access, and then read it with VB.
    if i created the db with office access, would you have to have office access installed or just have the mdb file in the right location?

  26. #26
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: txt files (writing to and retrieving from)

    Just VB and the mdb file. The installer installs everything that you need. (I usually use Inno, though)

  27. #27

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by dglienna
    Just VB and the mdb file. The installer installs everything that you need. (I usually use Inno, though)
    what is inno?

  28. #28
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    if i created the db with office access, would you have to have office access installed or just have the mdb file in the right location?
    Didn't you read the earlier replies
    Quote Originally Posted by Joacim Andersson
    You could use an Access database so you only need to distribute the mdb file, the user doesn't have to have Access installed.
    Also, as I suggested earlier you should put the MDB file in the same folder as the application is installed so you can use App.Path to get the path to it.

  29. #29
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    what is inno?
    InnoSetup is a great freeware installer.

  30. #30

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by Joacim Andersson
    Didn't you read the earlier replies
    Also, as I suggested earlier you should put the MDB file in the same folder as the application is installed so you can use App.Path to get the path to it.
    my screen reader must have missed it

  31. #31

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by Joacim Andersson
    InnoSetup is a great freeware installer.
    ill have to check it out

  32. #32
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by BrailleSchool
    my screen reader must have missed it
    Oh, I'm sorry I didn't know you needed a screen reader.

  33. #33

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by Joacim Andersson
    Oh, I'm sorry I didn't know you needed a screen reader.
    no apology needed.

  34. #34
    Member m0ney$'s Avatar
    Join Date
    Apr 2005
    Location
    Michigan
    Posts
    58

    Re: txt files (writing to and retrieving from)

    Are you making a guitar tab writer?
    Nick

  35. #35

    Thread Starter
    PowerPoster
    Join Date
    Apr 2005
    Location
    Debug.Print
    Posts
    3,885

    Re: txt files (writing to and retrieving from)

    Quote Originally Posted by m0ney$
    Are you making a guitar tab writer?
    Nope, making a translator from English to Irish Gaelic and from Irish Gaelic to English (using SSTab) and soon to be an access db

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