if you look at my example again you will see i have a counter variable called "x" this is what does the picking of the elements in the array
What you have written is saying "for the whole array data structure equalling 0-9 do all this other stuff"
So that is wrong you want to have For counter =0 to 9 instead there
The next problem is this line
Do while valid <> guest()
You are trying to compare a String with a Array object so you will get a data type mismatch you need to compare the variable valid with each element in the array
valid = InputBox("Ur name?")
Integer counter = 0
Do while valid <> guest(counter) OR counter<10
valid = InputBox("re-enter ur name")
loop
Just to confuse you i would do the cook like above read it and see if you understand that look at how the array is being used and the use of OR


Crashing Higher Computing?
Started by verticalforce, Jun 07 2006 03:31 PM
67 replies to this topic
#61
Posted 22 January 2007 - 05:09 PM
If i am not here i am somewhere else
#62
Posted 22 January 2007 - 05:33 PM
Tell me if I understand this correctly:
valid = InputBox("Ur name?")
Integer counter = 0
Do while valid <> guest(counter) OR counter<10
valid = InputBox("re-enter ur name")
loop
The integer counter is set to 0 to properly intialise it at first? Since there is 9 guests, the counter is put as <10?
Why is it OR and not AND.. hmmm...
Do I have to do this whenever I loop an array?
DAMMIT lol... having a teacher who can't teach vb and don't even know vb is depressing... (he can only do BASIC and our coursework is coming shortly and we haven't revised vb for months!)
valid = InputBox("Ur name?")
Integer counter = 0
Do while valid <> guest(counter) OR counter<10
valid = InputBox("re-enter ur name")
loop
The integer counter is set to 0 to properly intialise it at first? Since there is 9 guests, the counter is put as <10?
Why is it OR and not AND.. hmmm...
Do I have to do this whenever I loop an array?
DAMMIT lol... having a teacher who can't teach vb and don't even know vb is depressing... (he can only do BASIC and our coursework is coming shortly and we haven't revised vb for months!)
#63
Posted 22 January 2007 - 05:47 PM
I tried the code but got caught in the loop of death..it just kept looping at the same part although i've inputted the correct answer..
arghh...
arghh...

#64
Posted 22 January 2007 - 05:52 PM
yeh tht is why you have the infinite loop is cos o my error you should use AND
If i am not here i am somewhere else
#65
Posted 22 January 2007 - 06:02 PM
Thanks. It works... Lol.. that piece of programming took me ages to do and I am not even 1/20 through the program yet....
Don't worry, the code that I gave doesn't even look remotely like the coursework, only the steps are similar...
EDIT: The program works but it will only accept the first value after I retry it.. maybe this had to to with the counter = 0?
Don't worry, the code that I gave doesn't even look remotely like the coursework, only the steps are similar...
EDIT: The program works but it will only accept the first value after I retry it.. maybe this had to to with the counter = 0?
#66
Posted 22 January 2007 - 06:14 PM
room = InputBox("Choose a room")
Do While room < 1 Or room > 5 Or room = 3
room = InputBox("The selection might have been out of range. (Note: Room 3 is booked)")
Loop
ok, what I am trying to do here is to notify the users that room <1 or >5 is out of range and that room 3 is booked. How do I seperate these 2 things? Is it possible to do a loop in a loop? (hope this makes sense)
I am suppose to show that a room is reserved and another selection has to be made. Do I create the scenario myself or is there a proper way to do it?
Do While room < 1 Or room > 5 Or room = 3
room = InputBox("The selection might have been out of range. (Note: Room 3 is booked)")
Loop
ok, what I am trying to do here is to notify the users that room <1 or >5 is out of range and that room 3 is booked. How do I seperate these 2 things? Is it possible to do a loop in a loop? (hope this makes sense)
I am suppose to show that a room is reserved and another selection has to be made. Do I create the scenario myself or is there a proper way to do it?
#67
Posted 22 January 2007 - 09:57 PM
It is possible to do nested loops but this makes the algorithm less efficient, avoid it if you can!
It makes more sense to loop only when the conditions arent met, so you want to do something like:
if(room > 1 && room <5)
if(room == 3) (note this double equals is just a personal thing i use in psuedocode so as not to confuse it with assignment)
print "room booked choose another"
Edit: Just ignore this, someone delete it please.
It makes more sense to loop only when the conditions arent met, so you want to do something like:
if(room > 1 && room <5)
if(room == 3) (note this double equals is just a personal thing i use in psuedocode so as not to confuse it with assignment)
print "room booked choose another"
Edit: Just ignore this, someone delete it please.
#68
Posted 23 January 2007 - 05:14 PM
Thanks for all of your help. I think I know enough to start my coursework now.
Thanks again.
Thanks again.
2 user(s) are reading this topic
0 members, 2 guests, 0 anonymous users