English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I need to create a mini program which includes a Do While loop!!! this is the code below i need to do it for a password i need to make it so it only allows that password! look at the code andu you will understand!!

Dim password As Integer

password = InputBox("What is your password? ", "Please enter your password")
Do While password <> jim06fr
password = InputBox("Sorry. " & password & " is incorrect. Please try again. Please re-enter your password", "Password")
Loop
MsgBox("Welcome , your password is correct!", MsgBoxStyle.OkOnly, "Welcome")

it wont allow me to have that password (jim06fr) it has a blue line underneath says its not declared

WHAT DO I DO??? HELP! PLEASE QUICK!!

Thanks! QUICK HELP would be nice!! thanks again!

2006-12-20 07:47:06 · 8 answers · asked by Loz 1 in Computers & Internet Programming & Design

8 answers

put jim06fr in quotes like this

Do While password <> "jim06fr"

2006-12-20 07:55:13 · answer #1 · answered by Joe 4 · 2 0

Yes, the problem is that the password needs to be in quotes.

Do While password <> "jim06fr"

The reason for the blue line is that without the quotes, VB will treat it as a variable rather than as a string.

2006-12-21 07:21:28 · answer #2 · answered by Daniel R 6 · 0 0

Visual basic is a great first language because it is very forgiving as far as programming languages go. In about an hour you can be up and creating simple calculation programs using VB. There are many great tutorials on the web that can help you get started. Just make sure you know which version of VB you are using. The older VB6 is much simpler than the newer VB.NET 2005. There really arent any languages to learn before VB because it is so simple. However, it can be a very powerful language. Good luck.

2016-05-23 01:34:49 · answer #3 · answered by Anonymous · 0 0

Why have you defined your password as an integer and then test it as a string?

Dim password as string * 20
password=""
do
password = inputbox . . .
if password = "abc123" then
exit loop
end if
msgbox "Try again . . .
loop
Then you can include a count, vary the error mesage and so on.

Hope this helps

2006-12-20 08:06:52 · answer #4 · answered by Anonymous · 0 0

try putting the password inside the marks

Do While password <> jim06fr

Do While password

2006-12-20 07:50:09 · answer #5 · answered by SWIFT 3 · 0 1

Put quotes around the "jim06fr" if that is the actual password and not a variable.

2006-12-20 07:50:45 · answer #6 · answered by Anonymous · 5 0

you need to use double quotes around string
Do While password <> "jim06fr"
If you have no quotes VB thinks it is a variable

2006-12-20 09:01:32 · answer #7 · answered by v-1 2 · 0 0

you need to put your inputbox line inside the do while loop.

Otherewise it loops without asking for the password again.

This works :

Dim password

Do While password <> "ballbags"
password = InputBox("Password:")
Loop

2006-12-20 08:00:28 · answer #8 · answered by funchop 3 · 1 1

fedest.com, questions and answers