Results 1 to 7 of 7

Thread: [2008] - VB - Application To Decide Outcome

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    111

    Question [2008] - VB - Application To Decide Outcome

    Hi All,

    I've been asked to write an application that will evaluate a user's answers and decide on an outcome. The question's themselves will have the standard Yes / No as responses.

    I was thinking of storing the questions in a DB but I am not quite sure ATM if this is the best path to take.

    For example, if a user selects "Yes" to Q1, they are taken to Q3. If no is selected, they are taken to Q2. Upon answering to many NO's, the application will inform them that they can not continue. Any suggestions / links would be much appreciated.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] - VB - Application To Decide Outcome

    If the questions aren't going to change regularly then you'd probably want to hard-code that. Choosing a course based on the outcome would be more difficult if the questions are coming from elsewhere. I guess you could have a column containing the ID of the next question they answer Yes and another for the next question if they answer No. That could work.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    111

    Question Re: [2008] - VB - Application To Decide Outcome

    Thanks for the suggestion . The questions themselves will always remain static. I'm now stuck at how to increment to the correct question based on the selection. Any suggestions?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2008] - VB - Application To Decide Outcome

    The Question table in the database would have ID, Text, YesID and NoID columns. You would start by getting the Question with ID 1 and display its Text. If the user answered Yes you would get its YesID value and if the user answered No you would get its NoID value. You would then get the next question by getting the Question with the ID you got from the user's response. That would continue until the you get a response from the user that doesn't have a corresponding ID. At that point you can do whatever you deem to be appropriate.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [2008] - VB - Application To Decide Outcome

    I dont understand why you are going down the database route when you have just said that the questions will be static. Why not just hard code them?
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: [2008] - VB - Application To Decide Outcome

    Even hardcoded I would follow the outline that JM laid out. However, if it was hardcoded, I would make up a small class that has the members that he listed. You would then have a List of that class. Each class would keep a member that would hold the index of the No question, and the index of the Yes question. You could have a single method that accepted a boolean (True=Yes, False=No), and returned the index of the next question, or returned -1 if the user was an obstinate fool who could not continue. The implementation would be pretty similar.
    My usual boring signature: Nothing

  7. #7
    Hyperactive Member
    Join Date
    Apr 2005
    Location
    Indiana
    Posts
    451

    Re: [2008] - VB - Application To Decide Outcome

    Since you are using Visual Studio 2008, it may be beneficial to use Windows Workflow Foundation.

    This article may help you decide.

    http://msdn.microsoft.com/en-us/library/cc709416.aspx
    Ben


    Using Visual Basic 2005/2008

Posting Permissions

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



Click Here to Expand Forum to Full Width