|Home > Software > Drag-n-Drop Using Visual Basic > Example3 for Drag & Drop Type Question|
Visual Basic 6 : Drag-n-Drop Tutorial
4.1 Brief Description of Example3
Example 3 is slightly different from Example2.
This example (project) contains Drag & Drop for fill in the blanks type questions.
Also it explains how to display the blank spaces in middle of the question
Here control for answer option is created in the design view as control array (i.e. minimum no. of option given are 12)
These options are dragged and dropped on the required places
Fig9 Design view of the form for Drag & Drop fills in the blanks type questions
In the question two or more blank spaces may contain the same answer.Same answer is stored in the database for this
Observe the below table structure, here AnsSrNo 1 & 2 has the same answer
While giving Answer option to candidate only one option is given
That means duplicate Answer column is omitted.
For this small function is written which checks for duplicate answer colums
Private Function checkforcaption(strcaption As String) As Boolean
Dim i As Integer
For more details of coding you can download below zip file (dragdropdemo2.zip) Which gives you the clear idea of the entire project
For example the question stored in the database may be looks as shown below
Import java.io. *;
public ** void (** )
Note: *(star) in the question is for fill in blanks where candidate can drop the correct answer.
To retrieve the question field from table, a query is executed
For this first create a connection object and open the connection using ‘Open’ method
Next create recordset object where you can pass SQL statement to get the required records from particular table.
For Example to retrieve the Question field from table following query is written
Select Question from table name;
The above query displays all the records of the Question field from specified table.
After retrieving the question field we can bind the value of this field to required control or any variable.
In this project a procedure named displaythequestion is written. In this procedure value of the Question field is assigned to a String variable.
Procedure is written such a way that fist it extracts question, stored in the string variable. And based on the no. of question, control for question is created and question string is displayed in it.
Next it extracts the special character (**) from the question, stored in the string variable and depending on the no. of special character, control for the same is created.
Another procedure ‘displaythestring’ called inside the ‘displaythequestion’ procedure
Which combines the question with blanks and displays the whole question.
The method or technique used for dragging the control from source to destination is same as Example1. i.e. event procedure used to drag & drop control from source to destination is same.
Extra feature added in this example is Drag Over event of target object
This event is explained below
Private Sub lblsetcorans_DragOver(Index As Integer, Source As Control, X As Single, Y As Single, State As Integer)
If State = 0 Then
lblsetcorans(Index).BackColor = Source.BackColor
When we drag a source to a target when the mouse pointer is over the taget its backcolor is set to source backcolor with state=0 and when source is dropped to target its color is set back to the original color with state=1
Fig 10 Screen shot for Drag & Drop question Control before dragging to the target
Fig11 Screen shot for Drag & Drop type question control after being dragged to the target
Fig10 shows how control for question, fill in blanks and answer option is displayed
Fig11 is the Screen after the control is dragged and dropped in fill in blanks (i.e. in place of Placeholder)
4.2 Database Design
AnsRnd Number ‘used to display the answer option randomly to candidateQid Number
4.3 downloadable Zip file
5.1 Msdn Library Visual Studio6.0
|Home Copyright © 2003-2016 TutorialsWeb.com Disclaimer Sitemap|