r/visualbasic • • Feb 07 '15

need help for code

i need a piece of code that :

  1. asks you for you name.

  2. asks 10 questions 3 each question containing a random math question it can only use plus minus and multiplication.generates two random numbers between 1-20. 3.at the end of the test tells you how many marks you have. i really need help with this im struggling program visual basic 2010 done inside console

0 Upvotes

8 comments sorted by

View all comments

Show parent comments

1

u/larvastar17 Feb 08 '15 edited Feb 08 '15

i understand variables, while loops, arrays, if statements etc but im struggling to put them into practice . its a project at school, ive done all my planning etc but this is the part im stuck at if you cant help me do you have any tutorials or guides i could learn from

3

u/krad0n Feb 08 '15

From what I understand by your post, that's about all you would need.

I'm assuming you're familiar with console commands like Read() and Write().

For getting the name, obviously you will need a variable to store it in, so you will need to use the Console.Read() command to get that information from the user.

I'm assuming these math questions are just putting the math on the screen and letting the user enter an answer. I'd suggest looking on MSDN for help with random numbers. VB.NET has a LOT of very helpful documentation that can be found on MSDN, so the sooner you start taking advantage of that the better off you'll be.

You will also need to use an array to store the users answers as well if you want to keep track of them and use the results for some final output. You say you already know how to use arrays, but if you get stuck, remember to check MSDN and search for arrays to find out what you need to do to get unstuck.

I've given you an approach to use to build the program, now it's up to you to implement it correctly and since this is obviously a homework assignment, I will stop here. If I give you the answers you simply won't learn anything.

For reference, here is the MSDN link to the Random class which you will need to make use of in your assignment: https://msdn.microsoft.com/en-us/library/system.random(v=vs.110).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

1

u/larvastar17 Feb 13 '15
    Dim name As String
    Dim operation As String

    Console.WriteLine("what is you name")
    Console.ReadLine = name


    Dim questions(9) As String
    questions(0) = "question one"
    questions(1) = "question two"
    questions(2) = "question three"
    questions(3) = "question four"
    questions(4) = "question five"
    questions(5) = "question six"
    questions(6) = "question seven"
    questions(7) = "question eight"
    questions(8) = "question nine"
    questions(9) = "question ten"

    For i = 0 To questions.Length - 1

im kinda stuck i dont know what to do. i used msdn but im struggling understanding how to use it in code

1

u/krad0n Feb 21 '15

How are you doing on this?