Results 1 to 2 of 2

Thread: Little Vb Help PLZ!

  1. #1
    Join Date
    Apr 2007
    Posts
    1,259
    Rep Power
    0

    Exclamation Little Vb Help PLZ!

    Ok heres the thing i've discovered the cool things that VB can do and since in just starting out i'm just gonna stick with vb for a while enough talking.... Here's ma prob:

    I have a lil bro and i thought it would be cool to write him a lil math game in vb now this is how the current project looks


    You must be wondering by now whats my aim

    well here it is i want any time i press the problem button it generates a problem, i've done that but the thing is i want when i press the problem button(C2) again it gives me another problem...... ok lets say i got that resolved (i really haven't just for saying sakes)

    Next thing i want when my lil bro enters the the answer right it brings up a message box saying "correct" but heres that thing i have to find a way so that when he enters the answer in the text box (T2) it can be link to the orginal prob in the label(L1) so its something like this

    "he presses the problem button a problem appears in the label"
    "When he enters the correct answer he gets a message box saying correct if wrong it says 'wrong try again'
    I want to find a way to create a string between the button->text-> label thats all.......
    www.carhuntja.com - Buy and Sell Cars in Jamaica! - Coming Soon
    www.blackspade-ent.com - Jamaicas #1 Online Community
    www.mybbunlock.com - Instant Blackberry Unlocks Only 9.99 USD
    www.starallianceja.com - Negril's #1 In Entertainment

  2. #2
    Join Date
    Dec 2004
    Posts
    1,181
    Rep Power
    0

    Default

    ok. For what you wanna do, you can use a datatable with three datacolumns to store:

    1. A question ID
    2. The question
    3. The Answer

    For populating this table with the questions, you have two options; an external datasource (database, text file or xml file) or you can hard code the questions in your vb.net code. Considering you are new to vb.net, I would say hard code it for now. The limitation is that you will have to recompile the program if you wanna add questions. But, for right now, you want to get everything up and running, so hard code it in.

    Now, lets say you wanna store 50 questions, then you start populating the datatable with the question id datacolumn running from 0-49. Then when you want to fetch a new question, generate a random number between 0 and 49. Based on the generated number, fetch the corresponding question from the datatable. The lable's text property would set the question like so:

    Code:
    lable.text = datatable.row(generated_random_number).item(1)
    //the .item(1) refers the data in the second column since the first column has an index of 0.
    When he enters his answer, test it against the answer column which you could reference like so:

    Code:
    datatable.row(generated_random_number).item(2)
    //with .item(2) reffering to the third column, the answer column.
    If he gets it right, simply change the labels text property to "Correct" or "Wrong! Ha Ha" if he gets it wrong.

    Another tip; store the random generated integer variable globally. Meaning declare it withing the class but outside of all your methods. This ensures that all methods can access the same variable.

    I hope this will give you a head start. It was fun helping out since I love working with .NET. If you have any more questions, just post it. Happy Coding!
    'If we're supposed to work in Hex, why have we only got A fingers?'

    Follow Me: @psybuck2002us

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •