Lompat ke konten Lompat ke sidebar Lompat ke footer

VB.NET Guess The Word Game Source Code

How To Make Guess The Word Game In VB.Net

net tutorial we will see how to build a Guess The Word Game using vb VB.NET Guess The Word Game Source Code


in this visual basic .net tutorial we will see how to build a Guess The Word Game using vb.net programming language .


Watch The Full Tutorial



- The Project Source Code


Public Class Form1

    Dim words() As String = {"potato", "tomato", "computer", "appartment", "forest", "chocolat", "lawyer"}
    Dim item As Integer = 0
    Dim random As Random = New Random()
    Dim score As Integer = 0

    ' button start
    Private Sub Btn_Start_Click(sender As Object, e As EventArgs) Handles Btn_Start.Click

        item = 0

        TextBox1.Text = ""
        Label_Result.Text = ""
        score = 0

        displayWord()

        Btn_Next.Enabled = True

        Btn_Start.Enabled = False


    End Sub


    ' button display the next word
    Private Sub Btn_Next_Click(sender As Object, e As EventArgs) Handles Btn_Next.Click

            checkWord()

        If item < words.Length - 1 Then

            item += 1
            displayWord()


        End If




    End Sub


    ' create a function to display the word
    Public Sub displayWord()

            Dim pos1 As Integer = System.Convert.ToInt32(((random.Next((words(item).Length)))))
            Dim pos2 As Integer = System.Convert.ToInt32(((random.Next((words(item).Length)))))
            Dim pos3 As Integer = System.Convert.ToInt32(((random.Next((words(item).Length)))))

            Dim word As String = words(item)
            Dim wee As String = ""

            word = word.Remove(pos1, 1).Insert(pos1, "_")
            word = word.Remove(pos2, 1).Insert(pos2, "_")
            word = word.Remove(pos3, 1).Insert(pos3, "_")

            Label_Word.Text = word

        
    End Sub

 
    create a function to check if the player entred the correct word
    Public Sub checkWord()
        If words(item).Equals(TextBox1.Text) Then
            Label_Result.Text = "Correct"
            Label_Result.BackColor = Color.Green
            score += 1
        Else
            Label_Result.Text = "Wrong"
            Label_Result.BackColor = Color.Red
        End If


        If item = words.Length - 1 Then

            Label_Result.Text += " ( " & score & " / " & words.Length & " )"
            Label_Result.BackColor = Color.DarkViolet

            Btn_Start.Enabled = True

        End If

        TextBox1.Text = ""

    End Sub



End Class



OUTPUT:

net tutorial we will see how to build a Guess The Word Game using vb VB.NET Guess The Word Game Source Code

net tutorial we will see how to build a Guess The Word Game using vb VB.NET Guess The Word Game Source Code

net tutorial we will see how to build a Guess The Word Game using vb VB.NET Guess The Word Game Source Code

net tutorial we will see how to build a Guess The Word Game using vb VB.NET Guess The Word Game Source Code

net tutorial we will see how to build a Guess The Word Game using vb VB.NET Guess The Word Game Source Code



Posting Komentar untuk "VB.NET Guess The Word Game Source Code"