ASP.NET
  Home arrow ASP.NET arrow Coding an IQ Test with Conditionally Drive...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Coding an IQ Test with Conditionally Driven Event Handlers in ASP.NET 3.5
By: Codex-M
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 3
    2010-03-16

    Table of Contents:
  • Coding an IQ Test with Conditionally Driven Event Handlers in ASP.NET 3.5
  • Conditional Visual Basic Statements to Check Answers
  • Computation of mental age, IQ and displaying results on the browser
  • Complete Default.aspx.vb Source Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Coding an IQ Test with Conditionally Driven Event Handlers in ASP.NET 3.5


    (Page 1 of 4 )

    This is the second part of a tutorial series on developing conditionally-driven event handlers in ASP.NET 3.5. In part one, you started learning how to build an online IQ test with ASP.NET 3.5; the creation of web forms and setting of objectives were discussed. In this second part, we'll really sink our teeth into using conditionally-driven event handlers to make the test work.

    Specifically, in this part you will learn how to create the Visual Basic program that will serve as a server side script to handle conditional decisions of the web application. A typical decision making task includes determining whether the user has the correct answer to the question and then assigning scores.

    If you read part one and have fully created the web form (Default.aspx) in your own Visual Web Developer Express 2008, then let’s get started. All scripts mentioned in this article will be added to the Visual Basic file of Default.aspx in Visual Web Developer Express (Default.aspx.vb)

    Variable Declaration and Grabbing of Form Inputs

    Visual Basic is a “strong type” programming language. This means that you need to declare the type of all variables used in the script. In Visual Basic, the following are the important variable types and their application:

    Also, the Visual Basic server side script cannot do anything without having form values to be processed. These act as inputs to the scripts, which will then be processed and output the IQ of the person to the web browser. In Visual Basic, to grab the user inputs from the web form which is submitted to the ASP.NET server, the following is the syntax:

    Dim VisualBasicVariable As VisualBasicVariableType = FormIDused.Text

    The bolded words are the ones that need to be changed depending on the variable name you used and the type you need to assign to each of those variables. FormIDused is the text box web control ID declared in Part 1, like test1, test2, etc.

    To simplify the program, you will need to name those variables related to the form imputs as simply as possible. For example:

            Dim Answer1 As Object = test1.Text

            Dim Answer2 As Object = test2.Text

            Dim Answer3 As Object = test3.Text

            Dim Answer4 As Object = test4.Text

            Dim Answer5 As Object = test5.Text

            Dim Answer6 As Object = test6.Text

            Dim Answer7 As Object = test7.Text

            Dim Answer8 As Object = test8.Text

            Dim Answer9 As Object = test9.Text

            Dim Answer10 As Object = test10.Text

            Dim Point1 As Integer

            Dim Point2 As Integer

            Dim Point3 As Integer

            Dim Point4 As Integer

            Dim Point5 As Integer

            Dim Point6 As Integer

            Dim Point7 As Integer

            Dim Point8 As Integer

            Dim Point9 As Integer

            Dim Point10 As Integer

            Dim chronologicalage As Integer = age.Text

            Dim mentalage As Integer

            Dim IQ As Decimal

     

    The user's answers from the web form (variable Answer1 to Answer10) use the Object variable type because they are loosely defined (the answers can take the form of numbers, text, etc).

    Dim Answer1 As Object = test1.Text

    This above variable declaration line means “get the value of Textbox form ID name as test1 and then assign it to Answer1 as object.” So the answer for test question 1 using test1 form ID will be assigned as Answer1 in Visual Basic.

    What about the score? The score assigned to Answer1 will simply be called Point1, and so on and so forth. The scoring system is as shown below:

    Both correct and wrong answer points are integer values, therefore the variable type used in Visual Basic for those values is of the Integer type.

    Chronological age and mental age also use the Integer type, since human age in years is commonly expressed as integers.

    Lastly, the IQ can be expressed as a decimal, although during presentation of results back to the web browser, we can truncate or round off the values to be more user-friendly.

    More ASP.NET Articles
    More By Codex-M


     

    ASP.NET ARTICLES

    - ASP.NET 3.5: User Access Rules
    - ASP.NET 3.5: Creating Role Based Security wi...
    - ASP.NET 3.5 Role Based Security and User Aut...
    - Canonicalizing DotNetNuke URLs in ASP.NET 3.5
    - ASP.Net 3.5: User Account Creation for Your ...
    - ASP.NET 3.5 Basic User Account Management
    - Generate Dynamic Title Tag based on QueryStr...
    - Add a Blog Module in DotNetNuke
    - ASP.NET 3.5 Basic Navigation Controls
    - Create ASP.NET 3.5 Sitemap XML for Navigatio...
    - Completing Basic DotNetNuke Website Developm...
    - DotNetNuke Website Development in ASP.NET 3.5
    - ASP.NET Querystring: Basic Dynamic URL Forma...
    - InsertItemTemplate FormView Example in ASP.N...
    - Using the FormView Web Control in ASP.NET 3.5





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 10 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek