.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

test your IQ

Posted By:papsantony       Posted Date: July 30, 2010    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  

are you intelligent now choose
 

Imports System.Data.OleDb

Public Class startexam
    Dim d As DateTime
    Dim con As OleDbConnection
    Dim cmd As OleDbCommand
    Dim dr As OleDbDataReader
    Dim str As String
    Dim i, j, m As Integer





    Private Sub startexam_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Label18.Text = Form1.TextBox2.Text
        d = DateTime.Now
        Timer1.Enabled = True

        con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\iq\exam.mdb")
        con.Open()
        Dim r As Random = New Random
        i = r.Next(1, 30)

        str = "select * from Questions where Qno=@a"
        cmd = New OleDbCommand(str, con)
        cmd.Parameters.AddWithValue("@a", i)

        dr = cmd.ExecuteReader
        If dr.Read Then
            j = j + 1
            Label5.Text = j.ToString

            Label7.Text = dr(1).ToString
            Label13.Text = dr(2).ToString
            Label14.Text = dr(3).ToString

            Label15.Text = dr(4).ToString
            Label16.Text = dr(5).ToString
        End If
        dr.Close()
        con.Close()




    End Sub


    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Dim d1 As DateTime = DateTime.Now
        Dim span As TimeSpan
        Dim q, q1, q2 As Double
        q = 15.0

        span = d1.Subtract(d)
        Label3.Text = span.Minutes & "." & span.Seconds.ToString
        q2 = Double.Parse(Label3.Text)


        If (q2 > q Or j = 21) Then
            con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\iq\exam.mdb")
            con.Open()
            str = "update Userdetails set Mark=@a1 where Rollno=@s"
            cmd = New OleDbCommand(str, con)
            cmd.Parameters.AddWithValue("@a1", m)
            cmd.Parameters.AddWithValue("@s", Label18.Text)
            cmd.ExecuteNonQuery()
            con.Close()
            final.Show()



        End If



    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\iq\exam.mdb")
        con.Open()

        Dim r As Random = New Random
        i = r.Next(1, 30)

        str = "select * from Questions where Qno=@a"
        cmd = New OleDbCommand(str, con)
        cmd.Parameters.AddWithValue("@a", i)

        dr = cmd.ExecuteReader
        If dr.Read Then
            j = j + 1
            Label5.Text = j.ToString

            Label7.Text = dr(1).ToString
            Label13.Text = dr(2).ToString
            Label14.Text = dr(3).ToString

            Label15.Text = dr(4).ToString
            Label16.Text = dr(5).ToString
        End If
        dr.Close()
        con.Close()


    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\iq\exam.mdb")
        con.Open()
        str = "select * from Questions where Qno=@a2"
        cmd = New OleDbCommand(str, con)
        cmd.Parameters.AddWithValue("@a2", i)

        dr = cmd.ExecuteReader
        If dr.Read Then
           
            If ComboBox1.SelectedItem = dr(6).ToString Then
                m = m + 1
            End If
        Else
            MsgBox("Select Any one")

        End If
        dr.Close()
        con.Close()
    End Sub
End Class

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend