-
[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?
-
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.
-
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.
-
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.
-
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.
-
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
-
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.)
-
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.
-
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.
-
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.
-
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.
-
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.
-
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.
-
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:
sConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\theMDBFile.mdb;"
-
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?
-
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?
-
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.
-
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)
-
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.
-
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?
-
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.
-
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?)
-
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.
-
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.
-
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?
-
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)
-
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?
-
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.
-
Re: txt files (writing to and retrieving from)
Quote:
Originally Posted by BrailleSchool
what is inno?
InnoSetup is a great freeware installer.
-
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
-
Re: txt files (writing to and retrieving from)
Quote:
Originally Posted by Joacim Andersson
ill have to check it out
-
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.
-
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. :)
-
Re: txt files (writing to and retrieving from)
Are you making a guitar tab writer?
-
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 :)