Creating a quiz using visual basic 6

Preview:

DESCRIPTION

Visual Basic Simple Program

Citation preview

Creating a Quiz Using Visual Basic

6.0Ella Marie M. Wico

IV-Pope Pius IX

Objectives:

•Creating multiple Forms in 1 project.

Jargon Buster:(Definition of Terms)

Progressbar is an animated bar usually used to see if there is a page that is to be loaded.

Form is the start of the program when the application is first run. The Form looks like a blank application window you see when you open any Visual Basic software program. 

Timer executes code at regular intervals by causing a timer event to occur

PictureBox displays graphics Form bitmap, icon, or metafile, JPEG or GIF files

TextBox displays information entered at design time, entered by the user with a toggle choice

If then Else, an IF block statement is used to check whether the logical test is true or false. It will take the course of action based on the result retrieved on the logical test.

<Name of Form>.Show allows the user to go automatically to the next question/Form

Me.Hide allows the user to hide the current Form

Steps in Making a

Visual Basic Game

Part I: User

Interface

Form 1 (Log In)

1. Open Visual Basic 6.0 portable and create a new Standard EXE Project

2. First insert additional control in the toolbox2.1 Go to the Project Menu and then choose Components.2.2 On the Components dialog box, choose the controls that are needed in the program.

2.3 Choose Microsoft Windows Common Controls 6.0 2.4 Click Apply and then Close.2.5 The Toolbox will have additional controls like the picture shown below.

3. Create this interface.

3.1 Drag the Form in the size you want.3.2 Change its Caption in the Properties Window.Change it into “Welcome to Visual Basic Quiz”

3.3 Click the Picturebox in the toolbox3.4 Drag it into the size you want.3.5 In the Properties window, select the picture you want in you file. Then select it.

3.6 Click Label on the toolbox3.7 Create a label and then change its caption into “Name:” 3.8 Create another label and then change its caption into “Section:”3.9 Create a text box beside the two labels.

3.10 Create a command button and change its caption to “Enter”

4. Save your Form, CTRL + S, create a folder wherein you can save your files. In the filename: name your 1st Form as “frmlogin” then click Save.

Form 2 (Loading)

1. Create this interface.

1.1 Set the backcolor of the Form to black1.2 Set the backstyle of label to transparent and its forecolor to white 1.3 On the Properties Window of Timer, set the timer interval into 100.

.4 Click the ProgressBar on the Toolbox

2. Save your form, CTRL + S, save your file in the folder that you’ve made earlier. In the filename: name your 2nd form as “frmloading” then click Save

Form 3 (Question 1)

1. Create this interface

1.1 Click the PictureBox in the toolbox1.2 Drag it until it has the same size as the form1.3 Choose your desired picture, and then select it.

1.4 Create a Frame and then change its back color to blue1.5 Change its Caption to “Question # 1”

1.6 Create a label inside the frame and change its Caption to your desired question “This is considered to be the lowest level of programming language”1.7 Create a text box under it

1.8 Create a command button and change its Caption into “Next Question”2. Save your form, CTRL + S, save your file in the folder that you’ve made earlier. In the filename: name your 3rd form as “frmquestion1” then click Save.

Form 4 (Question 2)

1. Create this interface

And then repeat steps 1.1 to 1.7 on the previous form.1.8 Create a Command button and change its Caption into “Result”2. Save your form, CTRL + S, save your file in the folder that you’ve made earlier. In the filename: name your 4th form as “frmquestion2” then click Save.

Form 5 (Result)

1. Create this interface

1.1 Create a Frame1.2 Inside the frame, add labels naming: Name, Section, Correct, and Number of Items

1.3 Create a Command button naming “Quit”1.4 Save your form, CTRL + S, save your file in the folder that you’ve made earlier. In the filename: name your 5th form as “frmresult” then click Save.

Part II: Coding

Form 1 (Log In)

1. Double click the Enter command button, write these codes

Private Sub cmdenter_Click() If txtname.Text = "" Or txtsection.Text = "" Then MsgBox "You need to fill up the fields needed!", vbOKOnly + vbInformation, "Test" Else frmloading.Show Me.Hide frmresult.lblname.Caption = txtname.Text frmresult.lblsection.Caption = txtsection.Text End IfEnd Sub

2. Click CTRL+S to save

Form 2 (Loading)

1. Double click the Timer, write these codes

Private Sub Timer1_Timer() ProgressBar1.Value = ProgressBar1.Value + 1 If ProgressBar1.Value = 10 Then Label1.Caption = "Loading." ElseIf ProgressBar1.Value = 20 Then Label1.Caption = "Loading.." ElseIf ProgressBar1.Value = 30 Then Label1.Caption = "Loading..." ElseIf ProgressBar1.Value = 40 Then Label1.Caption = "Initializing."

ElseIf ProgressBar1.Value = 70 Then Label1.Caption = "Please Wait." ElseIf ProgressBar1.Value = 80 Then Label1.Caption = "Please Wait.." ElseIf ProgressBar1.Value = 90 Then Label1.Caption = "Please Wait..." ElseIf ProgressBar1.Value = 100 Then Label1.Caption = "Successful!" Timer1.Enabled = False frmquestion1.Show Me.Hide End IfEnd Sub

2. Click CTRL+S to save

Form 3 (Question 1)

1. Double-click the Next Question Command Button and enter these codes

Private Sub Cmd1_Click() If txtans1.Text = "Machine Language" Then frmresult.LBLSCORE.Caption = Val(LBLSCORE) + 1 frmquestion2.Show Me.Hide ElseIf txtans1.Text <> "" Then frmquestion2.Show Me.HideEnd IfEnd Sub

2. Click CTRL+S to save

Form 4 (Question 2)

1. Double-click the Result Command Button and enter these codes

2. Click CTRL+S to save

Form 5 (Result)

1. Double click the Quit command button, enter these codes below.

Command1

2. Click CTRL+S to save

Part III: Testing

1.Press F5 on your keyboard to execute your program

Saving

1. Go to the first form

2. Save the program as an .EXE file (executable) from the Menu bar, click File then choose MakeProject1.exe

3. Name your executable file as "Microsoft Visual Basic Game" then save it to the folder you created a while ago

The The EndEnd