Jump to content
  • Advertisement
Sign in to follow this  
Colin333

BASIC help

This topic is 3778 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey I've just started up learning the basics of BASIC again and I was curious why this code won't work:
username$ = Input$( "To Log in Type your username.")
password = Input( "Please type in your password.")

If password = 11032 And username$ = Colin Then 
[Print "Welcome back " + username$ + "."] 

	Delay 2000

Print "Please click To continue."

	WaitMouse 
End

For Some reason it completely skips the entire line that I put in brackets (Please note that I don't actually surround them with brackets when I imput the code) I use the old free demo of BlitzBasic. [Edited by - Colin333 on June 14, 2008 5:08:47 PM]

Share this post


Link to post
Share on other sites
Advertisement
In the line

If password = 11032 And username$ = 11032 Then..

username is a string but you are comparing to an integer.

I would think

If password = 11032 And username$ = "11032" Then...

would solve the problem, that or change username$ to an integer like password eg. username.


Edit:

You changed your code, but I think Colin in the line

If password = 11032 And username$ = Colin Then

is going to be seen as an integer variable in stead of a string.
You need to put quotes around string literals.

If password = 11032 And username$ = "Colin" Then

Share this post


Link to post
Share on other sites

;;;;;;;;;;;;;;;;
;Log in Program;
;;;;;;;;;;;;;;;;

username$ = Input$( "To Log in Type your username._")
password = Input( "Please type in your password._")

If username$ = "Colin" And password = 11032 Then
Print "Welcome back " + username$ + "!"

Delay 2000

Print "Hit any key to continue."

WaitKey

Else Print "Your username or password is incorrect."

WaitKey
EndIf

End

Code works perfectly, thanks again!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!