Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » A little help with Quickbasic.
Closed Thread
Old 03-06-2005, 03:17 AM   #1 (permalink)
 
Newb Techie

Join Date: Sep 2004

Posts: 20

P3t3r

Default A little help with Quickbasic.

Hi, I can't figure out what wrong is with this code... Anyone experienced with Quickbasic know what's wrong with it?

***********Start of code*************

DIM userid AS STRING 'Ask user for userid
DIM password AS INTEGER 'Ask user for password


CLS
COLOR 2

PRINT "Welcome to Peter's Secure Network Login System"
PRINT "Version 1.0"
SLEEP 2
PRINT "Please enter your User ID to continue."
INPUT "Userid"; userid
IF userid = Peter THEN
PRINT "Please enter your password to continue."
ELSEIF userid = Peteriscool THEN
PRINT "Please enter your password to continue."
ELSE
PRINT "Invaild Userid, you have 1 more chance to enter it again."
END IF

**********End of Code ***********
The program give me the type mismatch error on userid =Peter and userid= Peteris cool. When I add a $ to them, the program runs but not the way I want to. There is only 1 response instead of the 3 it suppose to have.

Thanks.
P3t3r is offline  
Old 03-06-2005, 10:11 AM   #2 (permalink)
 
Master Techie

Join Date: Apr 2004

Posts: 2,534

horndude is on a distinguished road

Default

you have to add a "$", thats how basic does strings

you elseif statements I think are wrong syntax maybe, been about 25yrs since I wrote anything in basic

google for quick basic and see if you can find an online manual and check the "if then" procedures/syntax
horndude is offline  
Old 03-06-2005, 11:21 AM   #3 (permalink)
macdude425's Avatar
 
Member (again)

Join Date: Jan 2005

Location: Raul's Wild Kingdom...How 'bout that, huh?

Posts: 4,200

macdude425 is on a distinguished road

Send a message via AIM to macdude425 Send a message via Yahoo to macdude425
Default

I think I found your problem.
Code:
IF userid = Peter THEN
PRINT "Please enter your password to continue."
ELSEIF userid = Peteriscool THEN
This needs to be:
Code:
IF userid = "Peter" THEN
PRINT "Please enter your password to continue."
ELSEIF userid = "Peteriscool" THEN
Since you defined userid as a string, all possible values have to be in quotes.

Hope that helps some.
__________________



Debian Support Forums!
macdude425 is offline  
Old 03-06-2005, 11:28 AM   #4 (permalink)
 
Master Techie

Join Date: Apr 2004

Posts: 2,534

horndude is on a distinguished road

Default

doesnt his input function need to be INPUT$ or not? Its been awhile LOL
horndude is offline  
Old 03-06-2005, 12:19 PM   #5 (permalink)
macdude425's Avatar
 
Member (again)

Join Date: Jan 2005

Location: Raul's Wild Kingdom...How 'bout that, huh?

Posts: 4,200

macdude425 is on a distinguished road

Send a message via AIM to macdude425 Send a message via Yahoo to macdude425
Default

Shouldn't have to be. I never use INPUT$, and all my programs work fine.
__________________



Debian Support Forums!
macdude425 is offline  
Old 03-08-2005, 08:04 PM   #6 (permalink)
 
Junior Techie

Join Date: Mar 2005

Posts: 52

JoeTheOdd

Send a message via AIM to JoeTheOdd Send a message via Yahoo to JoeTheOdd
Default

Code:
DIM userid AS STRING
DIM password AS STRING 'Text isn't an integer. You need to use a string.

CLS
COLOR 2

PRINT "Welcome to Peter's Secure Network Login System"
PRINT "Version 1.0"
SLEEP 2
PRINT "Please enter your User ID to continue."
USERIDINPUT: 'This is a place identifier, so we can call a GOTO later.
CALL INPUT("Userid", userid) 'Comma, not semicolon
IF userid = "Peter" OR userid = "Peteriscool" THEN 'More effecient to include the OR statment and test for either password
PRINT "Please enter your password to continue."
ELSE
PRINT "Invaild Userid. Please try again."
GOTO USERIDINPUT
END IF

JoeTheOdd is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On