🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.basic.visual.misc
Article #355

Re: HELP! I need a loop! Can't figure this...

#355
From: MikeG in Philly
Date: Sun, 12 Mar 2000 00:00
133 lines
4925 bytes
Hi Joe! Many thanks for taking the time to reply to me, but I just tried
this code and it doesn't work...it allows full access to the main form even
with a garbage password. I need something for class tomorrow, The idea is to
allow a user 3 tries to login and then exit the sub. Hope someone can
help...I have spent hours on this with no success...Mike

--------------------------------------------
"Joe "Nuke Me Xemu" Foster" <joe@bftsi0.UUCP> wrote in message
news:scm0r3mea5n96@corp.supernews.com...
> "MikeG in Philly" <PhilaPA@hotmail.com> wrote in message
news:38cae00b@news3.enter.net...
>
> > Hi Folks: the following code snippet is a loop for a password, and it
works
> > fine as it is...but I need to give the user three tries before exiting
the
> > sub and can't figure out the loop...can you help?
>
> > Here's the code...
>
>
> > Private Sub cmdOK_Click()
>
> > Dim strLName As String
> > Dim strPW1 As String
> > Dim strLevel As String
> > intCount = intCount + 1
>
> Is intCount a global, form-level, or static variable, or what?
>
> >     Open "a:\password.dat" For Input As #1
> >         Do While Not EOF(1)
> >         Input #1, strLName, strPW1, strLevel
> >
> >         If LCase(Trim(strLName)) = LCase(Trim(txtUserName.Text)) And
> > LCase(Trim(strPW1)) = LCase(Trim(txtPassword.Text)) And
>
> Why shouldn't the password be case sensitive? Check out StrComp in the
help.
>
> > LCase(Trim(strLevel)) = 3 Then
> >              frmMain.Show
> >              Me.Hide
> >              Close #1
> >              Exit Sub
> >
> >         Else
>
> Either use ElseIf or fix your indenting.
>
> >         If LCase(Trim(strLName)) = LCase(Trim(txtUserName.Text)) And
> > LCase(Trim(strPW1)) = LCase(Trim(txtPassword.Text)) And
> > LCase(Trim(strLevel)) = 2 Then
> >              Me.Hide
> >              frmMain.Show
> >              frmMain.cmdAssign.Visible = False
> >              frmTables.cmdOrders.Visible = False
> >              frmTables.cmdOL.Visible = False
> >              frmTables.cmdPurch.Visible = False
> >                 frmTables.cmdCR.Visible = False
> >                 Close #1
> >                 Exit Sub
> >         Else
> >         If LCase(Trim(strLName)) = LCase(Trim(txtUserName.Text)) And
> > LCase(Trim(strPW1)) = LCase(Trim(txtPassword.Text)) And
> > LCase(Trim(strLevel)) = 1 Then
> >         Me.Hide
> >         frmMain.cmdView.Visible = False
> >         frmMain.Show
> >         Close #1
> >         Exit Sub
>
> >         End If
> >         End If
> >         End If
>
> >         Loop
>
>
> >         Close #1
> >         MsgBox "Sorry, wrong password."
>
> > End Sub
>
> Here's how I might do it, based on what you've shown us:
>
> Open "a:\password.dat" For Input As #1
> Do While intCount > 0 And Not EOF(1)
>     Input #1, strLName, strPW1, strLevel
>
>     If StrComp(strLName, txtUserName.Text, 0) <> 0 Then
>         ' nope
>     ElseIf StrComp(strPW1, txtPassword.Text, 0) <> 0 Then
>         ' sorry
>     ElseIf strLevel = 3 Then
>         intCount = 0
>     ElseIf strLevel = 2 Then
>         intCount = 0
>         frmMain.cmdAssign.Visible = False
>         frmTables.cmdOrders.Visible = False
>         frmTables.cmdOL.Visible = False
>         frmTables.cmdPurch.Visible = False
>         frmTables.cmdCR.Visible = False
>     ElseIf strLevel = 1 Then
>         intCount = 0
>         frmMain.cmdView.Visible = False
>     End If
> Loop
> Close #1
>
> If IntCount = 0 Then
>     frmMain.Show
>     Me.Hide
> ElseIf IntCount < 3 Then
>     txtPassword.Text = vbNullString
>     txtPassword.SetFocus
>     MsgBox "Sorry, wrong password."
> ElseIf IntCount = 3 Then
>     MsgBox "Game over, man! Game over!"
>     Unload Me
> End If
>
> I'd really want to use at least a one-way hash for that password file.
>
> --
> Joe Foster <mailto:jfoster@ricochet.net>  Space Cooties!
<http://www.xenu.net/>
> WARNING: I cannot be held responsible for the above        They're
coming  to
> because  my cats have  apparently  learned to type.        take me away,
ha ha!
>
>
Technical Details
Message-ID: <38cb7cf5@news3.enter.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38cae00b@news3.enter.net> <scm0r3mea5n96@corp.supernews.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 110e3b,4281b5412007ec6b
X-Google-Attributes: gid110e3b,public
X-Google-Thread: 108062,4281b5412007ec6b
X-Google-Attributes: gid108062,public
From: "MikeG in Philly" <PhilaPA@hotmail.com>
Subject: Re: HELP! I need a loop! Can't figure this...
Date: 2000/03/12
Message-ID: <38cb7cf5@news3.enter.net>
X-Deja-AN: 596400039
References: <38cae00b@news3.enter.net> <scm0r3mea5n96@corp.supernews.com>
X-Original-NNTP-Posting-Host: atmax-2-37.enter.net
X-Trace: 12 Mar 2000 06:18:13 -0500, atmax-2-37.enter.net
Organization: Enter.Net
X-MSMail-Priority: Normal
X-Priority: 3
Newsgroups: comp.lang.basic.visual.misc,cz.comp.lang.basic.visual
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600