Click here to Skip to main content
15,891,859 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
Thanks to all the programmers out here I had a successful school project. Thank you again.

But now I want to carry the same idea into making a desktop exam application. I tried it on my own but I kept on getting stuck.
1. Because I figured i used session states in the web application.
2. Because I also figured there is no radio button-list equivalent in VB.net just radio button.

Below is a sample of the code I am using for the desktop exam application. Hope from there I will received the best of helps.

VB
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        RadioButton1.TabStop = False
        RadioButton2.TabStop = False
        RadioButton3.TabStop = False
        RadioButton4.TabStop = False

        Hour = 1
        minute = 0
        seconds = 0
        time.Text = Hour.ToString() & ":" & minute.ToString & ":" & seconds.ToString

        Dim a(4), t As Integer

        cnn.Open()
        cmd.Connection = cnn

        'This is a code for randomizing the questions
        Dim arbit As New Random
        Randomize()


        Dim I As Integer = 0
        While I <= 3
            t = arbit.Next(1, 25)
            If Array.IndexOf(a, t) = -1 Then
                a(I) = t
                I += 1
            End If
        End While

        For I = 0 To 4
            cmd.CommandText = "SELECT * FROM tblExamsQuestion where serial =" & a(I)
            adp = New SqlDataAdapter(cmd.CommandText, cnn)
            adp.Fill(ds, "tblExamsQuestionda")
        Next


        'this code is for creating new a table "preferably ANSWERED TABLE"
        dt = New DataTable("Answered")
        dt.Columns.Add("Serial", GetType(Integer))
        dt.Columns.Add("question", GetType(String))
        dt.Columns.Add("choice1", GetType(String))
        dt.Columns.Add("choice2", GetType(String))
        dt.Columns.Add("choice3", GetType(String))
        dt.Columns.Add("choice4", GetType(String))
        dt.Columns.Add("correct", GetType(String))
        ' dt.Columns.Add("explain", GetType(String))
        dt.Columns.Add("selected", GetType(String))


        'this code is for adding to the table TEST
        Dim r As DataRow

        For Each r In ds.Tables("tblExamsQuestionda").Rows
            dr = dt.NewRow
            dr("Serial") = dt.Rows.Count + 1
            dr("question") = r.Item("question")
            dr("choice1") = r.Item("choice1")
            dr("choice2") = r.Item("choice2")
            dr("choice3") = r.Item("choice3")
            dr("choice4") = r.Item("choice4")
            dr("correct") = r.Item("correct")
            'dr("explain") = r.Item("explain") 'if there is no column called explain, it will show error
            dr("selected") = ""
            dt.Rows.Add(dr)

        Next

        session = dt

        Call _show()

        If ctr = 0 Then
            BtnPrev.Enabled = False


        End If
        If ctr = 4 Then
            BtnNext.Enabled = False
        End If

        cnn.Close() 'connection closed
    End Sub


VB
Sub _show()

    dt = session
    'Dim v As View


    Dim l As Label
    l = Label1
    l.Text = dt.Rows(ctr).Item("Serial") & "."
    l = Label2
    l.Text = dt.Rows(ctr).Item("question")



    Dim r As RadioButton
    'r = CType(v.FindControl("RadioButtonList1"), RadioButtonList)
    r = RadioButton1
    ' r.Checked = False
    r.Text = (dt.Rows(ctr).Item("choice1"))
    r = RadioButton2
    r.Text = (dt.Rows(ctr).Item("choice2"))
    r = RadioButton3
    r.Text = (dt.Rows(ctr).Item("choice3"))
    r = RadioButton4
    r.Text = (dt.Rows(ctr).Item("choice4"))
    

    Session_ctr = ctr
End Sub



I hope with this I can get the best of helps. Help me to make the web application a desktop application
Posted
Updated 23-Jul-13 13:22pm
v4
Comments
Kschuler 23-Jul-13 10:55am    
This isn't really a question, it sounds a lot more like you're asking someone else to convert a web app into a desktop one for you. Instead of asking for general help, try to narrow it down. You said you tried but got stuck. What did you get stuck on? Give us that code and tell us why it didn't work or what error messages you got. Also, some of us haven't read any other questions you've posted...so instead of referencing them, give us the necessary details from it. For instance, if we knew more about why and how you were using the radio button list on your web project, perhaps we could suggest a windows forms control that would work best for you.
OsoJames 23-Jul-13 14:45pm    
@Kschuler, thanx for the reply. Its true what you said.
Now, I would like to narrow it down to the issue with the radio buttons. I used the radio button-list because all the radio buttons are seen as one. I could access a radio button by index. But with what I am trying out in the desktop application, I have to code for the radio buttons differently.
Kschuler 23-Jul-13 17:10pm    
Do you always have the same number of radio buttons, or at least a maximum number that you are using? If so, then simply put that many radio buttons on your form. You can access them very easily by name. If the number of buttons varies, and you have a maximum...you know you will never have more than five, for example....then put five on the screen and hide the ones you don't use for a given question. (I assume the radio buttons are used for multiple choice answers?)
OsoJames 23-Jul-13 18:48pm    
True, the radio buttons are being used for multiple choice answers. But the issue is, even though i can access them by their names, anytime I move to the next question by clicking a button called "Next", the selected radio button on the previous question, is already selected on the next new question.
OsoJames 23-Jul-13 18:57pm    
I've also changed the code i posted earlier to what I am trying to use for the desktop application. Which is not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900