Solved

saving and recurring text files.

Posted on 1998-06-16
25
138 Views
Last Modified: 2010-05-03
I have a Register screen it has a username(Text1), password(Text2), e-mail address (text3. I have got a text file with the username and e-mail address in it(marc.txt). when someone hits submit i want the program to look at the text file (marc.txt) and see if the username, password are real. If so End, If not go to form2. Also then save the password to a text file but call it marc2.hhh. the next person who uses this program will have to enter the password again and again i want it to save to a text file called marc2.hhh but not overwrite the previous saved password.


these are all my points sorry.
0
Comment
Question by:dog3
25 Comments
 
LVL 3

Expert Comment

by:greisch
ID: 1463390
Do you have marc.txt (and marc2.hhh) for user marc,
paul.txt for user paul, ... ?
Do you have marc.txt for all users ?
Do you have one or more users ?
The password is in marc.txt (with name & e-mail) ?
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463391
dog3
try this:
' I assume you saved the 3 items in the file in the order of
UserName  Password  Email

' Check passwaord
Dim lLine as String
Dim lInt as Integer
Dim lUserName as String
Dim lPswd as String
Dim fnum as Integer
Dim lValid as Boolean

lValid = False
fNum = FreeFile
Open "marc.txt" for input as fnum

Do while not EOF(fnum)
    Line Input #fnum, lLine
    lInt = Instr(lLine, " ")
    lUserName = Left(LLine, lInt-1)
    lLine = Right(lLine, Len(lLine)-Int)
    lInt = Instr(lLine, " ")
    lPswd = Left(lLine, lInt)
    If  lUserName = text1 and lPsWd = Text2 Then
            lValid = True
            Exit Do
         End if
    Loop
  If lValid = True then
      'Do what you do, end?
      Else
        form2.Show
    End If

Let me knoe if you have any questions
Regards
Dalin

   

0
 
LVL 1

Author Comment

by:dog3
ID: 1463392
Marc.txt has all usernames and domains.
Marc.txt is where i want the password to be stored.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463393
no you may of not read my comment after it.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463394
dog3,
I would suggest you put all username/paswd/email in one file (marc.txt) in a format:
UserName Password Email
dog3 yourPass dog3@anyMail.com
Dalin myPswd Dalin_N@MailExcite.com
Whoelse hispsword where@Ever.Com
.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463395
no you may of not read my comment after it.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463396
no you see i'm a system admin and i need 1 text file which has username and e-mail
then another which will collect the passwords.
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463397
dog3,
Do you mean you don't have your password in marc.txt yet?

0
 
LVL 1

Author Comment

by:dog3
ID: 1463398
no you see i'm a system admin and i need 1 text file which has username and e-mail
then another which will collect the passwords.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463399
no i do not have the password and want it in marc.hhh
but only in there if the username and e-mail are right.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463400
no i do not have the password and want it in marc.hhh
but only in there if the username and e-mail are right.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463401
the password and username are stored in marc.txt
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:Dalin
ID: 1463402
dog3,
Let me see if I understand you now..
You have a fiel called marc.txt containing  username and email
you have a file called marc.hhh tcontaining the password for the users in marc.txt.

When someone login, the/she supply you with a username/password/email via text1/text2/text3
If this username is in marc.txt and he give the right psword, OK
If the userName does not match the password then show form 2.

Please comment
Regards

0
 
LVL 6

Expert Comment

by:clifABB
ID: 1463403
This is so confusing!

I would suggest you drop the idea of a txt file and use either the registry or an ini file.  Both are much easier to read/write.
0
 
LVL 1

Author Comment

by:dog3
ID: 1463404
Ok here we go.
if username and e-mail address are in marc.txt
marc.hhh is empty.

when a person types in the right username and e-mail
store the password in marc.hhh

--------------------------Example of Marc.txt--------------
1
2
3
1@2.com for all users there are the same e-mail address.
-----------------------------------End marc.txt ---------------



0
 
LVL 1

Author Comment

by:dog3
ID: 1463405
ok you can use ini's
but make marc.txt, marc.ini
and marc.hhh, marc.ini
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463406
dog3,
So you do not want to use the password to validate?
As long as the username and e-mail matches what's in marc.txt, then valid?

But you do not have the userName and it's email in some corresponding way?

I thought your marc.txt file should be:
User1 user1@something.edu
User2 user2@whatever.com
User3 user3@somewhere.org
.
0
 
LVL 9

Expert Comment

by:cymbolic
ID: 1463407
Just a suggestion to simplify the issue.  Why not manually construct with an editor a sample of what you expect your two files to look like, on first use, and after the second use.  Then someone can use these to create and test code for you, if you can't do it your self by then.  I would recommend for program simplification that you go with a fixed length typed structure,then use binary file i/o to read/write the type.  Also, if storing passwords, use some type of encryption algorithm to avoid security problems.  

If your ultimate goal is just to track logons, note that in NT a security log data set is created by NT that can be saved automatically and imported into a database to retain searchable history.

 
0
 
LVL 1

Author Comment

by:dog3
ID: 1463408
stuff the e-mail part

all usernames are in marc.ini/txt (whatever)
ok if the e-mail box = "cabra" than it is valid
but if not "cabra" or "username" not valid and go to form2
if boath username and e-mail are valid store password in marc2.hhh/.txt/.ini

ok clear?
Marc.txt contains usernames
Marc2.txt contains the valid users passwords
and the e-mail box HAS to equal cabra lower caps.


0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463409
let me see if I understand...

'Check valid logon
       Dim lUserName as String
       Dim lPswd as String
       Dim fnum as Integer
       Dim lValid as Boolean
       dim fPsNum as Integer

       lValid = False
       If text3 = "cabra" then
           fNum = FreeFile
           Open "marc.txt" for input as fnum

           Do while not EOF(fnum)
           Line Input #fnum, lUserName
           If  lUserName = text1
                   lValid = True
                   Exit Do
                End if
           Loop
           Close #Fnum

         If lValid = True then
             'Store the password
             lPswd = Text2
             fNum = FreeFile
             Open "Marc2.txt" for Append as #fNum
             Print #FNum, lPswd
             Close #FNum
             Else
               form2.Show
           End If

0
 
LVL 1

Expert Comment

by:Sekans
ID: 1463410
I made a similar logon screen with Username/Password.  I stored the names and passwords in a password locked .mdb.  When the user submitted each I scanned the mdb for the username tested to see if the password matched, if it did...Welcome.  However, I realize this may not be the solution for you.  Just a thought.

Regards,
Sekans
0
 
LVL 1

Author Comment

by:dog3
ID: 1463411
i can't get this to work could you e-mail the whole project including the 2 text files to me then i wil give you the points.
0
 
LVL 9

Accepted Solution

by:
Dalin earned 160 total points
ID: 1463412
dog3,
I tested this code and it works like this:

If the email entry is cabra, it will go down the list of Username in the file marc.txt (the file only have username, with one in each line) to see if the entered user name is in the list. If yes, write the entered password to file marc2.txt.
Anyother cases, show form 2.
This is how I did it:

1. have a file edited, save as marc.txt, with content of:
dalin
Dog3
Who
somebady

2. start a new VB project
3. drop 3 text box, name them txtEmail, txtUserName, txtPassword
4. add another form
5. drop 1 command button, name it cmdLogin

6. In the cmdLogin_Click event, add the code:

Dim lUserName As String
Dim lPswd As String
Dim fnum As Integer
Dim lValid As Boolean
Dim fPsNum As Integer
Dim fPsNum As Integer

lValid = False
If txtEmail.Text = "cabra" Then
    fnum = FreeFile
    Open "C:\Dalin\marc.txt" For Input As fnum

    Do While Not EOF(fnum)
        Line Input #fnum, lUserName
             If lUserName = txtUserName.Text Then
                    lValid = True
                    Exit Do
                End If
        Loop
        Close #fnum
    End If

    If lValid = True Then
        'Store the password
        lPswd = txtPassword.Text
        fnum = FreeFile
        Open "C:\Dalin\Marc2.txt" For Append As #fnum
        Print #fnum, lPswd
        Close #fnum
    Else
        Form2.Show
    End If

End Sub

7.Run the project, enter cabra in txtEmail, dog3 in txtUserName, mypass in txtPassword, then click cmdlogin

Now you should have a file in c: called marc2.txt, with mypass in it.

8. again, enter something other than cabra in e-mail, you should see form2.

If you have problem, email me your project. My e-mail: Dalin_N@mailexcite.com

Regards
Dalin

0
 
LVL 1

Author Comment

by:dog3
ID: 1463413
Thanks!!!
0
 
LVL 9

Expert Comment

by:Dalin
ID: 1463414
dog3,
1. You can read the text file into a ftring variable since you do not need to show it.

Dim lString as String
Dim lLine as String
Dim fNum as Integer

Open "YourTxtFileWithPath.txt" for input as fnum
Do while not EOF(fnum)
     Line Input #fnum, lLine
     lString = lString & lLine
   Loop
Close #Fnum

Now lString has your txt File.

I was not clear on your 2nd question, can you clearify?
Regards
Dalin

>Thanks for doing that code it realy well.
>i was wondering if you knew how to load a text file into a hidden text =
>box?
>
>is there a way which you can type */www.txt  ?
>where the star is it means where ever the program is installed
>eg d:\1\ is where it is installed so www.txt is in d:\1\
>     c:\2\ is where it is installed so www.txt is in c:\2\
>ect please tell me=20
>thx
>
>
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now