array problem

frenchie_nic

Member
Joined
May 3, 2006
Messages
7
Programming Experience
Beginner
Hi all,
I am new to programming and to this site but i am giving it a go (well I did study a bit of Pascal in the past but didn’t make to much of it and it was a few years ago). I am trying to self teach myself the .net but I am having a problem and would like to understand the reason.
As a project I am trying to make a game that needs to generate a list of numbers then put it in an array if the number as not been chosen before. Then the next number is generated and checked against the existing array to see if the number as already been chosen (then if not then it is added to the existing array, etc.. u get the picture :D ). I have done most of it but I am coming up to a problem: when ever I try to check the number against the array, although when compiling I am seeing the value of the array as it should be (i.e. "1" "12" "9" etc, ), when I do my "
InStr" all I ever manage to do is compare one digit at the time even when double digit (i.e. if I have a number of 6, it will tell me its already in my string if I have 16 as it will check it against the 1 first and the 6 after but not against the value of 16.) I have tried other way but can’t get my head around so if someone could give me the right direction I would appreciate. I am not giving my code because I don’t want an answer in code but more a direction of what to look for.
Thanks J
Nic
Ps. I hope I made some sense in my question :p
 
i think you misunderstand how InStr work! InStr is to check the String position.

eg: ur arraylist
1) 1234 (value get from InStr is 2)
2) 1112 (value get from InStr is 4)

u key in "2" use InStr the first result will give u 2 and the second result will give u 4.
 
Ok, thanks a lots Albertkhor,
I did think I had the wrong impression of the InStr but wasn’t 100% sure. I have now managed to do what i was trying to acheive by passing each value of the string to a new one and comparing value against the random number. I did try this way before to put my first post, but it wasn’t working (my fault I had an index problem (forgot it was zero based... oops :) ) so it was going through a continuous loop... that should teach me) anyway, thanks for explaining that to me.
 
Back
Top