Using very basic coding in Visual Basic write a program that

Using very basic coding in Visual Basic, write a program that allows a user up to ten attempts at answering the question, “Which U.S. president was born on July 4?” The program must accept as a correct answer either the full name or just the last name. Also, only the last name needs to be spelled correctly.

After three incorrect guesses, the program should provide the hint, \"He once said, \'If you don’t say anything, you won’t be called upon to repeat it.\'\"

After seven incorrect guesses, the program should give the hint, “His nickname was ‘Silent Cal.’”

The total number of guesses submitted should be displayed on the screen. Note: Calvin Coolidge was born on July 4, 1872.

Please type the coding or, if hand-written, PLEASE make sure it is legible.

Solution

First design the page.

Drag and drop a label .Name it:which us president was born on july 4.

Drag and drop a textbox against the label

Below that drag and drop a button.Change the text of the button to Evaluate Answer

Below draga nd drop a label that says number of guesses

drag and drop a textbox against this label and make it read only..(option will be there at the side of the page,properties )

Public count as Integer=0; //declare a counter outside the buttonclick event.initialise to 0

Double click the button and write the below in the onclick button event

//buttonclick event

public Fullname as String= \" Calvin\" //write the full answer

public Lastname as String=\"Coolidge\" //write the last name of the answer

Public answer as String;

answer=textboxid.text; //takes the string that is entered in the textbox

If answer=Fullname Or answer=Lastname Then //checks if the value I entered matches fullname or the the lastname(calvin coolidge or coolidge)

MsgBox.Show(\"correct answer\",MsgBoxButtons.Ok) //message is shown if the above condition is true

Else

counter=counter+1; //if the entered answer is not right increase the counter by 1,number of attempts

GuessTextbox.text=counter; GuessTextbox is the id of the textbox against number of guesses label..Here counter value is assigned to this textbox to show how many guesses are over

If counter=3 Then //after three attempts

MsgBox.Show(\"Hint:He once said,\'If you dont say anything,you wont be called upton to repeat it\");

Else If counter=7 Then //after seven attempts

MsgBox.Show(\"His NickName was Silent Cal\");

Else If counter>10 Then //after 10 attempts

MsgBox.Show(\"You have crossed 10 attempts of answering the answer\");

Application.Exit();

Else

Dim Attemptsleft As Integer=10-counter;

MsgBox.Show(\"Wrong answer. \"+Attemptsleft+\" attempts more \",MsgBoxButtons.Ok);

End if

End If

Using very basic coding in Visual Basic, write a program that allows a user up to ten attempts at answering the question, “Which U.S. president was born on July
Using very basic coding in Visual Basic, write a program that allows a user up to ten attempts at answering the question, “Which U.S. president was born on July

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site