Jump to content

Completely new, please help

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
11 replies to this topic

#1
verion24

verion24

    Newbie

  • Members
  • Pip
  • 5 posts
Hi everyone,

I am making a quiz program in Visual Basic 6.0, where the question is answered in a text box, and, if correct, a certain number of marks is added to the displayed score as you go. However, i am confused about what coding for this needs to be done, and what the scored is displayed in (a label perhaps?). So, I ask, could someone give me so example code so i get the idea how to approach this? I know its a amatuer question, but I am having trouble getting my head around what coding to use in certain situations ('if' statements, calculations, etc). Also, could someone give me a good site to learn about this stuff? Also, hints, tips are appreciated.

Many Thanks in advance, I appreciate your help

#2
Guest_Jordan_*

Guest_Jordan_*
  • Guests
A label would be the easiest to display in. I'm not sure of the entire program so I really can't help you much. Maybe more details?

#3
verion24

verion24

    Newbie

  • Members
  • Pip
  • 5 posts
Hi there thanks for your help.

All questions are on the one form, and are shown in labels. When a user enters the correct answer in the textbox, below the label, I would like the score displaying label to add a certain number of marks, depending on the difficulty of the question. The score doesn't need to be added up at the end, just as-you-go. There will only be one correct answer in each question. The only objects that i assume require coding are the textbox, and the scoring label (and of course the 'exit' button, and one to return to the main menu, but I worked that out). If you could help, that would be great.

#4
Guest_Jordan_*

Guest_Jordan_*
  • Guests
What part of the program do you need help with? It may be best if you post the code that you have so far.

#5
verion24

verion24

    Newbie

  • Members
  • Pip
  • 5 posts
Hi there. I found out from another source that an 'if' statement is required. This is what i have done so far for the first question:
Private Sub txtquestion1_Change(Index As Integer)
If txtquestion1.Text = Beijing Then
lblscore.Caption = Format(txtquestion1.Text + 1)
End If
End Sub

The code does not work. The answer is beijing, and i am attempting to make the label add 1 mark if the answer is correct. Is the third line what you call a calulcation?

Thanks

#6
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
You need an "If" statement only to check if the answer is correct. Example:

Dim strAnswer as String
Dim intScore as Integer

strAnswer = Text1.Text

If strAnswer = "Beijing" then
intScore = intScore + 5 'marks given for particular question
Label1.Caption = "Current score is: " & intScore
End If

#7
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts

o0TheNerd0o said:

You need an "If" statement only to check if the answer is correct. Example:

Dim strAnswer as String
Dim intScore as Integer

strAnswer = Text1.Text

If strAnswer = "Beijing" then
intScore = intScore + 5 'marks given for particular question
Label1.Caption = "Current score is: " & intScore
End If

This one should work just fine. But I think that if you enter beijing instead of Beijing then it would be marked as wrong.

#8
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
then convert to all lower case using the LCase() function.

If LCase(strAnswer) = "beijing" Then

It will convert the entire string into lower case characters. You can also use th UCase() function which does the opposite. And another sugggestion, why not make the quiz multiple choice? That would solve your upper/lower case problem too.
Option Explicit
:cool:

#9
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
And will even make easier the coding and the user to answer the quiz.

#10
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
When building end-user applications... The less they have to do or worry about, the better. If they're concerned with upper or lower case, it becomes a headache for the user. Simple things like this will make your applications more user friendly.
Option Explicit
:cool:

#11
TcM

TcM

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 11,147 posts
The trick in having an application a success or failure is all in the GUI and user-friendliness. Take Windows as an example!

#12
o0TheNerd0o

o0TheNerd0o

    Learning Programmer

  • Members
  • PipPipPip
  • 61 posts
Didn't I just say that in the previous post? Lol!
Option Explicit
:cool: