Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
More help please!!!
#1
I have another problem and I don't know why.

""""""""""""""""""""""""""""""""""
INPUT "SELECT A LOCATION FOR THE TUBE OR A DESCRIPTIVE AREA OR ENTER YOUR OWN"; DES.3$
IF DES.3$ = "1" THEN
NAME.3$ = "FRONT LEG"
END IF
IF DES.3$ = "2" THEN
NAME.3$ = "REAR LEG"
END IF
IF DES.3$ = "3" THEN
NAME.3$ = "BASKET TUBE"
END IF
IF DES.3$ = "4" THEN
NAME.3$ = "CROSS TUBE"
END IF
IF DES.3$ <> "1-4" THEN
NAME.3$ = DES.3$
END IF
"""""""""""""""""""""""""""""""""""""""""""""

This is the code that I have and later on I print the name.3$. But no matter what I enter the name.3$ print always shows up as the des.3$ input. Unless I delete the following part.

"""""""""""""""""""""""""""""""""""""""""""""
IF DES.3$ <> "1-4" THEN
NAME.3$ = DES.3$
END IF
"""""""""""""""""""""""""""""""""""""""""""""

Can anybody tell me why?
thanks
chris
Reply
#2
Strings are not like numbers. If it's not literally 1-hyphen-4 in the string it will register that.

There is another, better way to do what you're doing known as SELECT CASE

Code:
SELECT CASE DES.3$
  CASE "1"
    NAME.3$ = "FRONT LEG"
  CASE "2"
    NAME.3$ = "REAR LEG"
  CASE "3"
    NAME.3$ = "BASKET TUBE"
  CASE "4"
    NAME.3$ = "CROSS TUBE"
  CASE ELSE
    NAME.3$ = DES.3$
END SELECT

You can also use ELSEIF with basic, and INPUT with numeric values

INPUT x
print x + 2

Use qb's help (press f1 in qb or click the "qboho" link above). It has an excellent index of every qb statement in its standard library.
i]"I know what you're thinking. Did he fire six shots or only five? Well, to tell you the truth, in all this excitement, I've kinda lost track myself. But being as this is a .44 Magnum ... you've got to ask yourself one question: 'Do I feel lucky?' Well, do ya punk?"[/i] - Dirty Harry
Reply
#3
Hopefullty this answers your question:

Code:
CLS
INPUT "SELECT A LOCATION FOR THE TUBE OR A DESCRIPTIVE AREA OR ENTER YOUR OWN"; DES.3%
IF DES.3% = 1 THEN
name.3$ = "FRONT LEG"
END IF
IF DES.3% = 2 THEN
name.3$ = "REAR LEG"
END IF
IF DES.3% = 3 THEN
name.3$ = "BASKET TUBE"
END IF
IF DES.3% = 4 THEN
name.3$ = "CROSS TUBE"
END IF

IF DES.3% < 1 OR DES.3% > 4 THEN
name.3$ = STR$(DES.3%)
END IF

PRINT "This is DES.3% :  "; DES.3%
PRINT "This is name.3$:  "; name.3$

Test it!
LA BLA BLA
Reply
#4
Like toon said, if you put "1-4" in brackets, it will only work when you actually type in "1-4".
LA BLA BLA
Reply
#5
Ok all, I am a little confused. Please try and help me out with this.

1st. The problem that I asked about. I tried your suggestion prof_flex, but I need the user to be able to enter an alphanumeric entry. The way you suggested to do it only let me enter a numeric number.

As for your suggestion toonski84, I don't really understand the use of the CASE command. Maybe if I show you what I am doing you can better explain it to me.

Here is the basic code of what I want.

"""""""""""""""""""""""""""""""""""""""""
CLS
PRINT "1.YES"
PRINT "2.NO"
PRINT "3.MAYBE"
PRINT
INPUT "SELECT YOUR ANSWER OR ENTER YOUR OWN"; ANSWER$
IF ANSWER$ = "1" THEN
ANS.1$ = "YES"
END IF
IF ANSWER$ = "2" THEN
ANS.1$ = "NO"
END IF
IF ANSWER$ = "3" THEN
ANS.1$ = "MAYBE"
END IF
IF ANSWER$ = (anything other then 1 to 3) THEN
ANS.1$ = ANSWER$
END IF
CLS
PRINT "YOUR ANSWER WAS"; ANS.1$
"""""""""""""""""""""""""""""""""""""""""""""""""

This is basically a real simplified version of what I would like to do. I want them to answer 1,2 or 3 or they can enter their own answer. But I want to later print it.

prof_flex how do I get the program to understand to do something if the answer is something other then the 1,2 or 3. Like if I want to say that if the answer is <> 1-3 then do this. How do I achieve this. I thought that using "1-3" would work. But I have been out of programming so long I don't remember anything. LOL

I appreciate the help guys.
Thanks
Chris
Reply
#6
Code:
CLS
PRINT "1.YES"
PRINT "2.NO"
PRINT "3.MAYBE"
PRINT
INPUT "SELECT YOUR ANSWER OR ENTER YOUR OWN"; ANSWER$
IF ANSWER$ = "1" THEN
ANS.1$ = "YES"
END IF
IF ANSWER$ = "2" THEN
ANS.1$ = "NO"
END IF
IF ANSWER$ = "3" THEN
ANS.1$ = "MAYBE"
END IF
ELSE
ANS.1$ = ANSWER$
END IF
CLS
PRINT "YOUR ANSWER WAS"; ANS.1$
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#7
Whitetiger0990 -
Thanks, but this doesn't work. I copyed and pasted exactly what you have and tried it, but I get an error that says ELSE without IF.
Reply
#8
An edit of whitetiger's code

Code:
CLS
PRINT "1.YES"
PRINT "2.NO"
PRINT "3.MAYBE"
PRINT
INPUT "SELECT YOUR ANSWER OR ENTER YOUR OWN"; ANSWER$
IF ANSWER$ = "1" THEN
ANS.1$ = "YES"
END IF
IF ANSWER$ = "2" THEN
ANS.1$ = "NO"
END IF
IF ANSWER$ = "3" THEN
ANS.1$ = "MAYBE"  
ELSE
ANS.1$ = ANSWER$
END IF
CLS
PRINT "YOUR ANSWER WAS"; ANS.1$
LA BLA BLA
Reply
#9
SELECT CASE works like this

Code:
CLS
PRINT "1.YES"
PRINT "2.NO"
PRINT "3.MAYBE"
PRINT
INPUT "SELECT YOUR ANSWER OR ENTER YOUR OWN"; ANSWER$

SELECT CASE ANSWER$
    CASE "1" : ANS.1$ = "YES"    
    CASE "2" : ANS.1$ = "NO"
    CASE "3" : ANS.1$ = "MAYBE"    
    CASE ELSE : ANS.1$ = ANSWER$
END SELECT
CLS
PRINT "YOUR ANSWER WAS"; ANS.1$
In a world without walls and doors, who needs Windows and Gates?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)