Thursday 16 September 2010

Visual Basic Tutorial - #7 - If, Elseif, Then, Endif, Rnd, Statements

Title:
Visual Basic Tutorial - #7 - If, Elseif, Then, Endif, Rnd, Statements


Video:


Description:In this tutorial we'll be covering the If, Then, Endif, Rnd statements. We're making a small game and I'll be giving you a small assignment to practise your skills with. Here's the code used: Dim Eyes As Integer Private Sub cmdResult_Click() Dim Guess As Integer Dim GuessS As String GuessS = txtGuess.Text Guess = CInt(GuessS) If Eyes = Guess Then txtResult.Text = "Correct, you win!!" Else txtResult.Text = "Wrong, you lose, noob!" End If End Sub Private Sub cmdThrow_Click() Eyes = Int((6 * Rnd) + 1) End Sub

Published:
17/Sep/2010

No comments:

Post a Comment