Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

need help please (new question at bottom)


  • This topic is locked This topic is locked

#1
MaverickSidewinder

MaverickSidewinder

    Member

  • Member
  • PipPipPip
  • 257 posts
I want to password protect an application. I got this:

Private Sub Form_Load()

lngBefore = Timer
Do
strAns = InputBox("What is the password?", "Password Required")
Loop Until Val(strAns) = Example
lngAfter = Timer
MsgBox "Correct Password", vbInformation

End Sub

When i run the form it asks me for a password. If i type directly ok it says: Correct Password. I press Cancel it says: Correct password. If i type anypassword it says: Password correct. How do i fix that?

Thanks again!

- Maverick

Edited by MaverickSidewinder, 15 June 2005 - 10:20 AM.

  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
Here's Modified Code

Private Sub Form_Load()

lngBefore = Timer
Do
strAns = InputBox("What is the password?", "Password Required")

'This was where your problem was
'The Val() thing and Example
Loop Until strAns = "The Password"

lngAfter = Timer
MsgBox "Correct Password", vbInformation

End Sub

  • 0

#3
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
Why a timer?
  • 0

#4
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Thank you stu_design :tazz:
  • 0

#5
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
NEW QUESTION!

Sub Form_Terminate()
MsgBox "You pressed the wrong command.", 48, "ERROR"
GoTo Form1
End Sub

If a person clicks on the X button this msgbox comes up. How can i either redirect him back to form1 when he presses the OK button or shade the X? :tazz: :tazz:
I improvised the GoTo Form1 thing... ;) ...its actually a real thing i think, but when i click ok when i run it it says: "Label Undefined"... ;)

Thanks!

- Maverick

Edited by MaverickSidewinder, 15 June 2005 - 10:34 AM.

  • 0

#6
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
lets say your current form is form2
instead of goto say
form1.Show
form2.Hide
or
form1.visible = True
form2.visible = false
  • 0

#7
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
I only have 1 form...
  • 0

#8
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
can you post all the code and were you are expecting that goto to go to
  • 0

#9
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Sub Form_Terminate()
MsgBox "You pressed the wrong command.", 48, "ERROR"
GoTo Form1
End Sub

No, i did not expect it but VB reads it as a real thing so im assuming its real, cause i typed: goto and it automatically changed it to GoTo.

Anyway, this is the code.
  • 0

#10
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
yea goto goes to a part of code but when your closeing the form it wont work
*******************
Load Form1
Form1.Show
*******************

try that code and heres an example of how goto works


1:
tones of code
GoTo 1

^ that particular example would be an edless loop of code
  • 0

Advertisements


#11
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
TwiztidNinja

Doesn't work. :tazz:
  • 0

#12
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
i dont quite get it sub Terminate executes when you press the Exit X in the corner right?
  • 0

#13
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
try
*********************
Load Form1
Form1.Visible = True
*********************
  • 0

#14
MaverickSidewinder

MaverickSidewinder

    Member

  • Topic Starter
  • Member
  • PipPipPip
  • 257 posts
Doesn't work. I need a code that brings me back to form1, not a code that lets me see it...
  • 0

#15
TwiztidNinja

TwiztidNinja

    Member

  • Member
  • PipPip
  • 51 posts
thats what the Load Form1 is thats just odd
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP