Code for Delete (button_click) (Manage Question) in vb.net

Ratings:
(4)
Views: 768
Banner-Img
Share this blog:

 

Code for Delete (button_click) (Manage Question)

Try

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = “Remove Question”

cmd.Parameters.Clear ()

cmd.Parameters.AddWithValue (“@ qid”, txtQuestionId.Text)

if cn.State = ConnectionState.Closed then

ex.Open ()

MessageBox.Show (“Question removed”, Me.Text)

ClearQuestion ()

Catch ex as Exception

MessageBox.Show (ex.Message, “Error”)

End try

Open UserForm (A new WINFORM)

Place pictureBox on Form

Set image = Select image (vb270 Online Examination)

Dock = Top

BackGround = White (Form)

Place a label Untitled Candidate Name

Online examination form  

Select Combobox & select use Databound items

Choose vb270Category OE

Display Member: Category Name

Value Member: Category Id

// Code for Formload (Userform)

Untitled Under user form

lblCName.Text = logicForm

Above TakeExam_buttonClick

Public Shared examid as Integer

// For TakeExam btn

‘Take Exam (button_click)

Examid = cmbExam.SelectedValue

Dim ef as New ExamForm

Me.Hide ()

Ef.ShowDialog ()

Me.Dispose ()

// Code for close button_click

End

  Exam form  

Place another Groupbox upon existing are

Place label 2nd Groupbox à Text

Text: Thank you for using vb270 Online Examination

Place label 2 on 2nd Groupbox

Please click on the [finish] button to view the results

For Groupbox2 – visible = false

For ExamForm_Load

Imports System.Data

Imports System.Data.SqlClient

- Under public class ExamForm

‘Form declarations

Dim cn as SqlConnection

Dim cmd as SqlCommand

Dim dr as SqlDataReader

Public Shared ds as DataSet

‘Form_Load

Cn = New Sql Connection (“user id = sa; password = 123; database = master; datasource = sekhar”)

Cmd = New SqlCommand

cmd.Connection = cn

cmd.CommandType = CommandType.Text

cmd.CommandText = “Select * from vb270 QuestionsOE where category id=” & userFrom Examid

if cn.State = ConnectionState.closed then cn.Open ()

dr = cmd.ExecuteReader

ds = New Dataset

ds.Tables.Add (“User Response”)

ds.Tables (0).Columns.Add (“Question”)

ds.Tables (0).Columns.Add (“CorrectAnswer”)

ds.Tables (0).Columns.Add (“User Answer”)

ds.Tables (0).Columns.Add (“Status”)

Showquestion ()

Go to ‘Form declarations

Public Sub ShowQuestion ()

If dr.Read = True then

lblQuestion.Text = dr.Getvalue (1)

rbtOption1.Text = dr.GetValue (2)

rbtOption2.Text = dr.GetValue (3)

rbtOption3.Text = dr.GetValue (4)

rbtOption4.Text = dr.GetValue (5)

Else

btnNext.Enabled = False

btnFinish.Enabled = True

GroupBoxQuestion.Visible = False

GroupBoxFinal.Visible = True

End if

End sub

// Code for ‘Next (button_click)

SetUserResponse ()

ShowQuestion ()

Again go to ‘Form declarations (exam form)

Public row SetUserResponse ()

Dim row as DataRow

row = ds.Tables (0).NewRow

row (0) = lblQuestion.Text

Select case dr.GetValue (6)

Case ls =1

Row (1) = rbtOption1.Text

Case ls = 2

Row (2) = rbtOption2.Text

Case ls = 3

Row (3) = rbtOption3.Text

Case ls = 4

Row (4) = rbtOption4.Text

End select

If rbtOption1.Checked then row (2) = rbtOption1.Text

If rbtOption2.Checked then row (2) = rbtOption2.Text

If rbtOption3.Checked then row (2) = rbtOption3.Text

If rbtOption4.Checked then row (2) = rbtOption4.Text

If row (1) = row (2) then

Row (3) = “Correct”

Else

Row (3)

End if

ds.Tables (0).Rows.Add (row)

rbtOption1.Checked = False

rbtOption2.Checked = False

rbtOption3.Checked = False

rbtOption4.Checked = False

End sub

  // Code for Finish_button

Dim rf as ResultsForm

Me.Hide ()

rf.ShowDialog ()

Me.Dispose ()

Project (menu) Untitled Add new form Untitled Results Form

  Online examination form  

‘Form Load (ResultsForm

lblName.Text = LoginForm.user

DataGridView1.DataSource = ExamForm.ds.Tables (0)

Dim totalQuestions, correctAnswers as Integer

totalQuestions = ExamForm.ds.Tables (0).Rows.Count

CorrectAnswers = 0

For r as Integer = 0 to

ExamForm.ds.Tables (0).Rows (r) (3) = “Correct” then

CorrectAnswers + = 1

Next

Dim Percentage as integer

Percentage = (CorrectAnswers * 100) / totalQuestions

Lbl CandidateScore.Text = String.Format (“Candidate Score ({0} marks)”, percentage)

If percentage > = 85 then

Lbl Result.text = “Pass”

lblResult.FOreColor = Color.Green

loginForm.AxAgent1.Characters (“Merlin”).Play (“Announce”)

loginForm.AxAgent1.Characters (“Merlin”).Play (“Congratulate_2”)

loginForm.AxAgent1.Characters (“Merlin”).Speak(String.Format (“Congrts {0} you have passed”, lblName.Text))

Else

lblResult.Text = “Fail”

lblResult.ForeColor = Color.Red

LoginForm.AxAgent1.Characters (“Merlin”).Play (“Sad”)

LoginForm.AxAgent1.Characters (“Merlin”).Speak (“Better luck next time” & lblName.Text)

End if

progressBarUsersCore.Value = Percentage    

For an in-depth knowledge, click on below

You liked the article?

Like: 0

Vote for difficulty

Current difficulty (Avg): Medium

EasyMediumHardDifficultExpert
IMPROVE ARTICLEReport Issue

About Author

Authorlogo
Name
TekSlate
Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.

Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox