Imports System.Data.OleDb
Imports System.Data
Imports System.Threading
Imports System.Data.SqlClient
Public Class Form1
Dim bm As BindingManagerBase
Dim ds As New DataSet
Dim adp As OleDb.OleDbDataAdapter
Sub showrecord(ByVal pos As Integer)
Button1.Text = ds.Tables(0).Rows(pos)("Question")
Button2.Text = ds.Tables(0).Rows(pos)("Option1")
Button3.Text = ds.Tables(0).Rows(pos)("Option2")
Button4.Text = ds.Tables(0).Rows(pos)("Option3")
Button5.Text = ds.Tables(0).Rows(pos)("Option4")
End Sub
Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
LabelX1.BackColor = Color.White
ds = New DataSet
Dim dt As New DataTable
Dim con As New OleDb.OleDbConnection("provider=sqloledb; server=MICROSOF-AE7D21SQLEXPRESS; database=mahaveer; userid=; password=;Trusted_Connection=yes;")
con.Open()
adp = New OleDb.OleDbDataAdapter("SELECT TOP 10 * FROM kbc ORDER By NEWID()", con)
adp.Fill(ds, "kbc")
bm = Me.BindingContext(ds, "kbc")
bm.Position = 0
showrecord(bm.Position)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim result As DialogResult = MessageBox.Show("Are You Sure", "Millionaire", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.OK Then
If Button2.Text = Button6.Text Then
bm.Position += 1
showrecord(bm.Position)
Else
Label2.Text = "Sorry Wrong Answer"
End If
End If
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim result As DialogResult = MessageBox.Show("Are You Sure", "Millionaire", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.OK Then
If Button3.Text = Button6.Text Then
bm.Position += 1
showrecord(bm.Position)
Else
Label2.Text = "Sorry Wrong Answer"
End If
End If
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim result As DialogResult = MessageBox.Show("Are You Sure", "Millionaire", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.OK Then
If Button4.Text = Button6.Text Then
bm.Position += 1
showrecord(bm.Position)
Else
Label2.Text = "Sorry Wrong Answer"
End If
End If
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Dim result As DialogResult = MessageBox.Show("Are You Sure", "Millionaire", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
If result = Windows.Forms.DialogResult.OK Then
If Button5.Text = Button6.Text Then
bm.Position += 1
showrecord(bm.Position)
Else
Label2.Text = "Sorry Wrong Answer"
End If
End If
End Sub
End Class
i have written a quiz game in this code. i have 12 labels from LabelX1 to LabelX12.
here i want their background color white one by one when a user click on the correct answer.
how can i do that ?
Software/Hardware used:
vb.net 2008
Discuss This Question: