Mynotoar
Active member
Hey there!
I started VB just over a month ago, we've been working with console applications - no GUI - and I've been having great fun with it. Recently - with every bit of help from wonderful forumers - I experimented using Lists to create a Periodic Table quiz, and now I had some more questions about lists.
Firstly and most simply, how do you use ranges in lists? For example, say I wanted to create a list of the numbers 1-100. I've noticed scrolling through options that there is .AddRange in a With tag, but I can't work out how to use it - none of the arguments I've tried are valid.
Secondly, how do you pick a random value from a list? For example, say I wanted to write a simple lottery number program, and so I create a list with all the possible numbers, then I need to randomly choose a value from that list and repeat that six or seven times - how would I go about doing that?
Third and lastly, how do you compare two lists in order? For example, say I'm writing a program which has four values, "Up", "Down", "Left" or "Right". Then say I wanted to create a random sequence of up, down, left and right, e.g. "Left Up Down Up Down", which would be stored in a List(Of String) as the correct sequence. Then the user inputs a sequence of these four values, and this is entered into another List(Of String) as the user-given sequence. What I want to do then would be to compare the two strings to check that they match.
So to conclude, my three questions:
1. How do you include ranges in lists?
2. How do you pick a random value from a list?
3. How do you compare the values of two lists in order to make sure they match?
I hope you can help, thank you in advance .
I started VB just over a month ago, we've been working with console applications - no GUI - and I've been having great fun with it. Recently - with every bit of help from wonderful forumers - I experimented using Lists to create a Periodic Table quiz, and now I had some more questions about lists.
Firstly and most simply, how do you use ranges in lists? For example, say I wanted to create a list of the numbers 1-100. I've noticed scrolling through options that there is .AddRange in a With tag, but I can't work out how to use it - none of the arguments I've tried are valid.
Secondly, how do you pick a random value from a list? For example, say I wanted to write a simple lottery number program, and so I create a list with all the possible numbers, then I need to randomly choose a value from that list and repeat that six or seven times - how would I go about doing that?
Third and lastly, how do you compare two lists in order? For example, say I'm writing a program which has four values, "Up", "Down", "Left" or "Right". Then say I wanted to create a random sequence of up, down, left and right, e.g. "Left Up Down Up Down", which would be stored in a List(Of String) as the correct sequence. Then the user inputs a sequence of these four values, and this is entered into another List(Of String) as the user-given sequence. What I want to do then would be to compare the two strings to check that they match.
So to conclude, my three questions:
1. How do you include ranges in lists?
2. How do you pick a random value from a list?
3. How do you compare the values of two lists in order to make sure they match?
I hope you can help, thank you in advance .