Creating a quiz using visual basic 6

65
Creating a Quiz Using Visual Basic 6.0 Ella Marie M. Wico IV-Pope Pius IX

description

Visual Basic Simple Program

Transcript of Creating a quiz using visual basic 6

Page 1: Creating a quiz using visual basic 6

Creating a Quiz Using Visual Basic

6.0Ella Marie M. Wico

IV-Pope Pius IX

Page 2: Creating a quiz using visual basic 6

Objectives:

•Creating multiple Forms in 1 project.

Page 3: Creating a quiz using visual basic 6

Jargon Buster:(Definition of Terms)

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

Page 4: Creating a quiz using visual basic 6

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. 

Page 5: Creating a quiz using visual basic 6

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

Page 6: Creating a quiz using visual basic 6

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

Page 7: Creating a quiz using visual basic 6

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

Page 8: Creating a quiz using visual basic 6

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.

Page 9: Creating a quiz using visual basic 6

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

Page 10: Creating a quiz using visual basic 6

Me.Hide allows the user to hide the current Form

Page 11: Creating a quiz using visual basic 6

Steps in Making a

Visual Basic Game

Page 12: Creating a quiz using visual basic 6

Part I: User

Interface

Page 13: Creating a quiz using visual basic 6

Form 1 (Log In)

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

Page 14: Creating a quiz using visual basic 6

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.

Page 15: Creating a quiz using visual basic 6
Page 16: Creating a quiz using visual basic 6

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.

Page 17: Creating a quiz using visual basic 6
Page 18: Creating a quiz using visual basic 6

3. Create this interface.

Page 19: Creating a quiz using visual basic 6

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”

Page 20: Creating a quiz using visual basic 6
Page 21: Creating a quiz using visual basic 6

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.

Page 22: Creating a quiz using visual basic 6
Page 23: Creating a quiz using visual basic 6

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”

Page 24: Creating a quiz using visual basic 6

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.

Page 25: Creating a quiz using visual basic 6

Form 2 (Loading)

1. Create this interface.

Page 26: Creating a quiz using visual basic 6

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.

Page 27: Creating a quiz using visual basic 6
Page 28: Creating a quiz using visual basic 6

.4 Click the ProgressBar on the Toolbox

Page 29: Creating a quiz using visual basic 6

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

Page 30: Creating a quiz using visual basic 6

Form 3 (Question 1)

1. Create this interface

Page 31: Creating a quiz using visual basic 6

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.

Page 32: Creating a quiz using visual basic 6
Page 33: Creating a quiz using visual basic 6

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

Page 34: Creating a quiz using visual basic 6
Page 35: Creating a quiz using visual basic 6

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

Page 36: Creating a quiz using visual basic 6

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.

Page 37: Creating a quiz using visual basic 6

Form 4 (Question 2)

1. Create this interface

Page 38: Creating a quiz using visual basic 6

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.

Page 39: Creating a quiz using visual basic 6

Form 5 (Result)

1. Create this interface

Page 40: Creating a quiz using visual basic 6

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

Page 41: Creating a quiz using visual basic 6

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.

Page 42: Creating a quiz using visual basic 6

Part II: Coding

Page 43: Creating a quiz using visual basic 6

Form 1 (Log In)

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

Page 44: Creating a quiz using visual basic 6

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

Page 45: Creating a quiz using visual basic 6

2. Click CTRL+S to save

Page 46: Creating a quiz using visual basic 6

Form 2 (Loading)

1. Double click the Timer, write these codes

Page 47: Creating a quiz using visual basic 6

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."

Page 48: Creating a quiz using visual basic 6

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

Page 49: Creating a quiz using visual basic 6

2. Click CTRL+S to save

Page 50: Creating a quiz using visual basic 6

Form 3 (Question 1)

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

Page 51: Creating a quiz using visual basic 6

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

Page 52: Creating a quiz using visual basic 6

2. Click CTRL+S to save

Page 53: Creating a quiz using visual basic 6

Form 4 (Question 2)

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

Page 54: Creating a quiz using visual basic 6
Page 55: Creating a quiz using visual basic 6

2. Click CTRL+S to save

Page 56: Creating a quiz using visual basic 6

Form 5 (Result)

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

Page 57: Creating a quiz using visual basic 6

Command1

Page 58: Creating a quiz using visual basic 6

2. Click CTRL+S to save

Page 59: Creating a quiz using visual basic 6

Part III: Testing

Page 60: Creating a quiz using visual basic 6

1.Press F5 on your keyboard to execute your program

Page 61: Creating a quiz using visual basic 6

Saving

Page 62: Creating a quiz using visual basic 6

1. Go to the first form

Page 63: Creating a quiz using visual basic 6

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

Page 64: Creating a quiz using visual basic 6

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

Page 65: Creating a quiz using visual basic 6

The The EndEnd