martin2k

ForumsVB6GamesSoftwareDirectoryHTMLArticlesBlogContact

How do I randomly sort questions from a database?


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

Question

From: Sarah Cheng
Date: Tuesday 18 December 2001 8:12 PM
Subject: re:message box
Question: Hi this sarah,
I have sent you my visual basic project.
Thanks for helping.

Answer in e-mail format:

Hi martin,
Thanks for the help, I handed my project in time.
Sarah
----- Original Message -----
From: Martin Allen
To: Sarah Cheng
Sent: Sunday, January 06, 2002 9:15 PM
Subject: RE: message box

Hello Sarah,
 
I finally got it to work properly.  I hope its not to late for your deadline.  I asked the guy at http://www.vb-helper.com who gave me some help with the random number code.


vb_52_quiz.zip
(48.4 KB)

If you need any more help with anything, please e-mail me or send a message to my forum.

-----Original Message-----
From: Sarah Cheng
Sent: Sunday 06 January 2002 2:01 PM
To: Martin Allen
Subject: Re: message box

hi martin,
yeh my deadline is monday 5pm.
I actually got the question to change each time it is loaded but now it won't let the contestant to select the number of questions they want to attempt. Whatever the contestant click on the option button, it will only allow the contestant to answer one question. I think it is something to do with the code in cmdquiz_click(). I don't know how to link the shuffling of questions with the number of questions being selected.
I send you the new version of my program to see if you can work it out for me.
thanks.
Sarah
 
----- Original Message -----
From: Martin Allen
To: Sarah Cheng
Sent: Sunday, January 06, 2002 12:19 PM
Subject: RE: message box

Hello Sarah,
 
I am working on a way to do this, but it is more complicated than I thought.  The code that I have at the moment doesn't work properly yet, but I haven't forgotten you!  Is your deadline tomorrow?

Martin Allen
http://www.martin2k.co.uk/vb6

-----Original Message-----
From: Sarah Cheng
Sent: Sunday 06 January 2002 12:20 AM
To: Martin Allen
Subject: Re: message box

hi martin,
in my quiz program, i made the question change each time the program is loaded, but i want the contestant to select the number of questions they want to attempt and the questions loaded in to the program to be different each time.
eg. bob selects option button 3.
Which means he wants to attempt three questions. the questions loaded in to the program should be different to the previous contestant questions.
Could you solve my problem please. I got it to change once, each time the program is loaded.
could you email by 6th jan.
thanxs
 
sarah. 
----- Original Message -----
From: Martin Allen
To: Sarah Cheng
Sent: Sunday, December 23, 2001 9:09 PM
Subject: RE: message box

Hello Sarah,
 
I figured out what both problems were.  The 3051 runtime error was caused by the files that you sent me being read-only so I turned that off.
 
Your invalid qualifier was caused because you did not type frmQuiz. before the txtName.Text, which meant Visual Basic could not find txtName.Text.
 
Your code:

Private Sub cmdSubmit_Click()

Dim response As Integer

If optAnswer(CorrectAns).Value = True Then 
response = MsgBox("Correct"&TxtName.text&)
Else
response = MsgBox("Wrong")
End If
Hide 
End Sub

End Sub

Correct code:

Private Sub correct()
Dim answer As Integer
 
answer = MsgBox("correct, " & frmQuiz.txtName.Text, vbOKOnly)
End Sub

Also, it isn't necessary to have 'correct' and 'incorrect' procedures when you could have it all in one procedure:

Private Sub cmdSubmit_Click()
Dim response As Integer
 
' Display a suitable message and exit the form
If optAnswer(CorrectAns).Value = True Then    ' User clicked correct answer
MsgBox "correct, " & frmQuiz.txtName.Text, vbOKOnly
Else
MsgBox "wrong, " & frmQuiz.txtName.Text, vbOKOnly
End If

Hide ' go back to main quiz form
End Sub
 
I should have worked out that the read-only files were causing the 3051 error.  Please contact me again if you have any further problems.

Martin Allen
http://www.martin2k.co.uk/vb6

-----Original Message-----
From: Sarah Cheng
Sent: Sunday 23 December 2001 8:26 PM
To: Martin Allen
Subject: Re: message box

Hello martin,
this quiz program, is one of my school project that i ahve to do.
I'm using visual working model package to do this project. I don't know if that helps you.
I have never had a run time error 3051.
The school sets up the project and we have to modify it.
I try sending the program again if that helps.
----- Original Message -----
From: Martin Allen
To: Sarah Cheng
Sent: Saturday, December 22, 2001 5:43 PM
Subject: RE: message box

Hello Sarah,
 
When I try to open the program, I get the error:
 
Run-time error '3051':
 
The Microsoft Jet database engine cannot open the file 'C:\WINDOWS\DESKTOP\New Folder\Quiz.mdb'.  It is already opened exclusively by another user, or you need permission to view its data.
 
I know this is a different error to what you get.  What do I need to do to correct this?  After this problem is solved, I maybe able to help you with your problem.
 
Thanks,

Martin Allen
http://www.martin2k.co.uk/vb6


blog comments powered by Disqus
Martin Allen 1999 - 2011.  Last updated Friday 12 August 2011 11:54:20 PM +0100.