Hello all,
I have one assignment left to finish my VB course. I have to finish it by this week or I will have to pay a late fine.
This is the program:
Write a program to run two separate threads printing numbers (or words) in ascending and descending orders. The numbers (or words) should be given by the user.
Now will I have to use a stack, or a queue, or something like that? Or would I only use Loops and Do-whiles? And can somebody jump-start me with a little bit of code?
Thanks
Loops and Do-While statements
Started by vbstudent, Jul 06 2010 08:03 AM
7 replies to this topic
#1
Posted 06 July 2010 - 08:03 AM
|
|
|
#2
Posted 06 July 2010 - 02:03 PM
Do you mean that you asks the user for the words, and then the two threads show the words? Thread one in ascending order and thread two in descending order? Can you also specify what kind of program you want to make? A console-program or one with a graphical user interface?
Floris
Floris
#3
Posted 07 July 2010 - 05:27 AM
Oh I'm sorry I was out all day yesterday and I realized that I forgot to add that. That is correct. It's a console application in Visual Basic 2008 Express. The program must ask the user for either a word or a starting number and an ending number. They both have to be printed in both ascending and descending order. Thank you for taking the time to help!
#4
Posted 07 July 2010 - 07:50 AM
I don't think I understand all you said, but I think you mean something like this:
If it isn't, please tell me and give some more information.
Floris
Dim inputs As New List(Of String)
Dim answer As String
Do
Console.WriteLine("Add a word to the list.")
inputs.Add(Console.ReadLine())
Console.WriteLine("Do you want to add another word? (y/Y = yes)")
answer = Console.ReadLine()
Loop Until (answer <> "Y" And answer <> "y")
inputs.Sort()
Console.WriteLine("Ascending order:")
For Each str As String In inputs
Console.WriteLine(str)
Next
Console.WriteLine("Descending order:")
For i As Integer = inputs.Count - 1 To 0 Step -1
Console.WriteLine(inputs.ElementAt(i))
Next
Console.ReadLine()
If it isn't, please tell me and give some more information.
Floris
#5
Posted 07 July 2010 - 02:05 PM
Hmm, tis could work, thamk you very much. However, there is a possibility that the teacher wants it to print every letter seerately and on seperate lines(If that makes sense?). Like i would input the word "thanks" and it would give me back:
Ascending:
T
h
a
n
k
s
Descending:
s
k
n
a
h
T
I have to wait for the teacher to get back to me on that one. But still this is much appreciated. I learned some new coding from this! If I could ever be of help to you, send me a pm!
Ascending:
T
h
a
n
k
s
Descending:
s
k
n
a
h
T
I have to wait for the teacher to get back to me on that one. But still this is much appreciated. I learned some new coding from this! If I could ever be of help to you, send me a pm!
#6
Posted 07 July 2010 - 02:19 PM
No problem :).
But one question: can I ask you what course you follow? Haven't you seen these types of loops? If not, you can ask your teacher for more explanation.
If you want your program working on the way you just explained, I suggest you to use this kind of code. Again, it's basic. You should add some extras, like giving the user the possibility to fill in multiple words.
But one question: can I ask you what course you follow? Haven't you seen these types of loops? If not, you can ask your teacher for more explanation.
If you want your program working on the way you just explained, I suggest you to use this kind of code. Again, it's basic. You should add some extras, like giving the user the possibility to fill in multiple words.
Dim input As String
Console.WriteLine("Give me a word, please.")
input = Console.ReadLine()
Console.WriteLine("ascending:")
For i As Integer = 0 To input.Length - 1
Console.WriteLine(input.Chars(i))
Next
Console.WriteLine("descending:")
For i As Integer = input.Length - 1 To 0 Step -1
Console.WriteLine(input.Chars(i))
Next
Console.ReadLine()
#7
Posted 07 July 2010 - 02:28 PM
Thanks that's great. Yeah i don't mind its from an online school and its called Programming: Visual Basic.NET and java. I'm not taking tha Java part yet though. But this course realy doesn't explain stuff too well, it wasn't good for beginners, and the teacher wasn't too helpful and took a long time to get back. But yeah its a really hard course for beginners not wanting to sound lazy here(Which this probably does). There was about 45 students that began the course, and only about 4 got to the end, including(barely) me. Thanks again for the help! Greatly appreciated!
#8
Posted 07 July 2010 - 02:43 PM
You're welcome. Maybe it's a good idea to look for tutorials on google. I'm not saying I'm good at programming, but I've learned it by doing that.
Floris
Floris


Sign In
Create Account

Back to top









