Hangman Game

Our VB Hangman game is originated from the paper and pencil guessing game for two or more players. The game starts with one player thinks of a word and the other player tries to guess it by suggesting letters within a certain number of guesses.

The hidden word is represented by a row of dashes, representing each letter of the word. If the player correctly guesses a letter in the word, the other player writes it down in all its correct positions. If the suggested letter does not occur in the word, the other player draws one element of a hanged man figure as a tally mark, starting with the head, following by the body then the arm and so forth.

In addition, the guesser has the option of guessing the whole word when he thinks he has enough clues. If the word is correct, the game is over and the guesser wins. Otherwise, the other player penalizes the guesser by adding an element to the diagram. On the other hand, if the guesser commits enough number of incorrect guesses that allows the opponent to complete the hangman diagram, the game is also over, and the guesser loses. However, the guesser can also win by guessing all the letters or numbers that appear in the word, before the diagram is completed.

In our program, we need to draw a hangman diagram. I suggest you use the Line control to draw the diagram. It is also advisable to convert the Line control into a control array so that we can program it easily using a Loop or the If…Then…Else statement. In addition, we also need to place several Label controls onto the form for the purpose of displaying the letters. These Label controls also need to be converted into a control array and also make invisible at startup or replaying the game. Besides that, we also need to place several Line control below the Label control and make them as a control array and invisible at startup. Last but not least, we also need to design a keyboard by placing 26 command buttons onto the form for the user to choose the alphabet. We follow the design of the standard computer keyboard. The buttons must also be converted to a control array.

We will show you how to write the code in our newest book, Visual Basic Sample Codes Made Easy Ed 2.0  to be launched soon. Please check back regularly.

The Interface


Visual Basic 2017 Made Easy is Released Today!

Dr.Liew has released his latest Visual Basic Made Easy series book, Visual Basic 2017 Made Easy today!  Be the first one to download this book and learn the newest  Visual Basic.NET programming language


Visual Basic 2017 Made Easy

Preview the book

Visual Basic 2017 Made Easy is a complete guide to mastering Visual Basic 2017, from beginner to intermediate programmers.  This book has been written to complement our free online Visual Basic 2017 tutorial with much more content. It is also an excellent reference text for high school or college-level computer science courses.

Reading this book will allow you to:

  1. Understand the basic concepts of Visual Basic 2017 programming
  2. Create your own Visual Basic 2017 applications from scratch
  3. Get inspiration from a variety of interesting sample programs
  4. Modify the code samples easily to suit your needs
  5. Learn how to package and distribute your applications

 


Deploying your Visual Basic 2017 Applications

Having developed a Visual Basic 2017 application, you might want to publish and distribute it to the users.

Before deploying your application,  you need to test and debug your application to ensure it is error-free.

Publishing your application is a very easy procedure, it just requires a few clicks. First of all, load your application in Visual Basic 2017. In this example, I wish to publish my Draw Text application. In the VB2017 IDE, choose Build and then select Publish Draw text, as shown in the following figure.

publish visual basic 2017

After clicking Publish Draw Text, the Publish Wizard will ask you to choose a location that you want to publish this application. You may publish the application on your local drive or to a remote location via FTP, as shown in the following figure:

Click the Next button to continue. Now, the Publish Wizard will ask you how will users install the application. There are three options,  from a website,  from a UNC path or file share and from a CD-ROM or DVD-ROM. In this example, we choose CD-ROM or DVD-ROM, as shown in the following figure:

You may click the Next button to continue with the Publish Wizard or the Finish button to complete the publishing process. If you click the Next button, the Publish Wizard will ask where will the application check for updates. In our example, we choose that the application will not check for updates, as shown in the following figure.

After clicking the Next button, the final screen of the Publish Wizard will show you where the application will be published to.

Upon clicking the Finish button, the installation files and folder will be saved to the specified location. In our examples, the folder is Application files and the files are Draw text.application and setup.exe. You may now burn the folder and files into a CD-ROM, DVD-ROM or upload them to a website for distribution to the users.

 


Creating Board Games in Visual Basic

We can create board games in Visual Basic. Creating board games require some basic knowledge of maths as we need to perform some calculations. For example, we need to use the knowledge of matrix to create a board for the snakes and ladders game. Besides that, we also need to write decision-making code to deal with board games, as shown in the reversi game, where we use the If…Then..Else statements to check how many white and black pieces appear on the reversi board and which positions they occupy.

In the case of Tic Tac Toe , we need to use the Boolean logic to check the adjacent slots are empty or not. In the game of Star War, we use the principle of the projectile in physics to chart the paths of motion.


Creating Financial Calculators

You can create all kinds of financial calculators in Visual Basic easily as long as long you know the relevant formulas.

For example, you can create a future value calculator using the following formula:

FV = PV * (1 + i / 100)n

FV=Future Value

PV=Present Value

i=Interest

n=Number of periods

You simply create a function for the future value, as follows:

Private Function FV(pv As Single, i As Single, n As Integer) As Double
FV = pv * (1 + i / 100) ^ n
End Function

You then write code for a button where it can compute the future value when the user clicks on the button, as follows:

Private Sub BtnCal_Click(sender As Object, e As EventArgs) Handles BtnCal.Click

Dim FutureVal As Single
Dim PresentVal As Single
Dim interest As Single
Dim period As Integer

PresentVal = TxtPV.Text
interest = TxtInt.Text
period = TxtN.Text
FutureVal = FV(PresentVal, interest, period)
LblFV.Text = Format(FutureVal, “$#,##0.00”)

End Sub

Some of the financial calculators created by us are: