Click here to Skip to main content
14,271,871 members

Visual Basic

 
AnswerRe: Source Convert VB.Net to C# Pin
ZurdoDev6-Aug-19 10:03
professionalZurdoDev6-Aug-19 10:03 
GeneralRe: Source Convert VB.Net to C# Pin
Eddy Vluggen6-Aug-19 12:20
mveEddy Vluggen6-Aug-19 12:20 
GeneralRe: Source Convert VB.Net to C# Pin
ZurdoDev6-Aug-19 14:59
professionalZurdoDev6-Aug-19 14:59 
AnswerRe: Source Convert VB.Net to C# Pin
Eddy Vluggen6-Aug-19 12:18
mveEddy Vluggen6-Aug-19 12:18 
QuestionSource Convert VB.Net to C# Pin
Baloch_khan6-Aug-19 8:58
memberBaloch_khan6-Aug-19 8:58 
Questionself talking hangman vb console game tutorial Pin
StarTrekCafe29-Jul-19 18:48
memberStarTrekCafe29-Jul-19 18:48 
AnswerRe: self talking hangman vb console game tutorial Pin
Afzaal Ahmad Zeeshan30-Jul-19 5:32
mveAfzaal Ahmad Zeeshan30-Jul-19 5:32 
GeneralRe: self talking hangman vb console game tutorial Pin
StarTrekCafe30-Jul-19 17:56
memberStarTrekCafe30-Jul-19 17:56 
hi, well pasting my code and errors below. no sniping or snide remarks. help me out with my errors, and a better way to get this to work please. will paste my code and then my errors. thanks. ps: pasting now.
Imports System.IO
Imports System.Media
Imports System.Speech.Synthesis
Imports System.Windows.Forms

' Program: Hangman
' Author: Marvin Hunkin
' Version: 1.1
' Date:  Tuesday December 25, 2012
' Description: Playing a Hangman game.  You enter a letter to use a list of words loaded into memory.  You  then guess a six letter word, and use 13 guesses. At the end of 13 guesses, you get a message saying you either won or loss, and what the word was, and a number to exit the game being 1.  Added a couple of cool sound audio effects.

Module Module1

    ' Declare class level variables

    Dim WordMask As String = "------"
    Dim WordArray() As String
    Dim Talker As New SpeechSynthesizer
    Dim Player As New SoundPlayer

    Sub Main()

        ' Create a new wordlist file path

        Dim wordlistPath = Path.Combine(Application.StartupPath, "Resources", "wordlist.txt")

        ' Populate the word array variable with the contents of the file path

        WordArray = File.ReadAllLines(wordlistPath)

        ' Show the window maximized and show the name of the application in the title bar

        Console.WindowWidth = 60
        Console.Title = "Hangman"
        Dim NewUri As Uri = Nothing
        Dim Result As Boolean = Uri.TryCreate(Directory.GetParent(Directory.GetCurrentDirectory).Parent.ToString + "\en-sc", UriKind.Absolute, NewUri)
        If Result Then
            Talker.AddLexicon(NewUri, SynthesisMediaType.Ssml)
            Talker.SelectVoice(0)
        End If

        ' Welcome message

        Console.WriteLine("Welcome To Hangman!")
        SpeakLines("Welcome To Hangman!")
        Console.WriteLine("This game is to be played by blind and visually impaired players.")
        SpeakLines("This game is to be played by blind and visually impaired players.")
        Console.WriteLine()

        ' Declare local variables

        Dim ContinuePlayingGames As Boolean = True

        ' While loop to play the game

        While ContinuePlayingGames
            PlaySound("Futile02.wav")
            Dim RandomIndex As Integer = GetRandom(0, (WordArray.Length - 1))
            Dim PickedWord As String = WordArray(RandomIndex)
            PlayAGame(PickedWord)
            Dim QuitRequested As String
            Console.WriteLine("Enter 1 to quit playing or Press Enter to play again")
            Console.WriteLine()
            SpeakLines("Enter 1 to quit playing or Press Enter to play again")
            QuitRequested = Console.ReadLine()
            If QuitRequested = "1" Then
                PlaySound("discon.wav")
                Console.WriteLine("Goodbye")
                SpeakLines("Goodbye")
                Exit While
            Else
                Console.Clear()
            End If
        End While
        Dim CloseRequested As String
        Console.WriteLine("Hit any key to close console.")
        Console.WriteLine()
        SpeakLines("Hit any key to close console.")
        CloseRequested = Console.ReadLine()
    End Sub

    ' Function to get the mask for the game

    Private Function RenderMask(ByVal Str As String) As String

        ' Declare local variables

        Dim temp As String = ""
        For Each Letter As Char In Str
            If Letter = "-" Then
                temp += "dash"
            Else
                temp += "the letter " & Letter
            End If
            temp += ", "
        Next
        Return temp
    End Function

    ' Function to speak lines in the Microsoft Samantha voice

    Private Sub SpeakLines(ByVal Str As String)

    End Sub

    ' Sub to play sounds for the game

    Private Sub PlaySound(ByVal Sound As String)

        ' Get the sounds and stream it to the game

        Player.Stream = File.OpenRead(Path.Combine(Application.StartupPath, "Resources", Sound + ".wav"))
        Player.PlaySync()
        Player.Stream.Dispose()
    End Sub

    ' Play A Game Sub starts here

    Private Sub PlayAGame(ByVal PassedWord As String)

        ' Declare local variables

        Dim EnteredLetter As String = ""
        Dim MatchedLetterCount As Integer = 0

        ' For loop to guess 1 to 13 moves

        Dim GuessCount As Integer = 0
        Dim TempMask As String = ""
        For GuessCount = 1 To 13
            Console.WriteLine(WordMask)
            SpeakLines("So far you have " & RenderMask(WordMask))
            Console.WriteLine("Guess Number - " + GuessCount.ToString + ", Enter A Letter")
            Console.WriteLine()
            SpeakLines("Guess Number - " + GuessCount.ToString + ", Enter A Letter")
            EnteredLetter = Console.ReadLine()
            SpeakLines("You entered the letter " & EnteredLetter)
            PlaySound("LaserBeamHit.wav")
            If EnteredLetter <> "2"(0) Then
                TempMask = WordMask
                MatchedLetterCount = CheckEnteredLetter(PassedWord, EnteredLetter, MatchedLetterCount)
                If TempMask <> WordMask Then
                    GuessCount -= 1
                End If
                If MatchedLetterCount = 6 Then
                    PlaySound("Bugle Reveille.wav")
                    Console.WriteLine("You Win!")
                    SpeakLines("You Win!")
                    Console.WriteLine("The word was " & WordMask)
                    SpeakLines("The word was " & WordMask)
                    WordMask = "------"
                    Exit For
                End If
            Else
                ShowMessage()
                GuessCount -= 1
            End If
        Next GuessCount
        Console.WriteLine("Sorry, you used up all 13 guesses, you lose!")
        SpeakLines("Sorry, you used up all 13 guesses, you lose!")
        Console.WriteLine("The word was " & PassedWord)
        SpeakLines("The word was " & PassedWord)
        WordMask = "------"
    End Sub

    ' Sub to show the message in the game

    Private Sub ShowMessage()

        ' Declare local variables

        Dim Title As String = "Program: Hangman."
        Dim MessageString As String = " Author : Marvin Hunkin." + vbNewLine + "Version: 1.1." + vbNewLine + "Date:  Tuesday December 25, 2012." + vbNewLine + "Description: Playing a Hangman game." + vbNewLine + "You enter a letter to use a list of words loaded into memory." + vbNewLine + "You  then guess a six letter word, and use 13 guesses." + vbNewLine + "At the end of 13 guesses, you get a message saying you either won or loss," + vbNewLine + " and what the word was, and a number to exit the game being 1." + vbNewLine + "Added a couple of cool sound audio effects." + vbNewLine + "Press Enter to Continue."

        Talker.Speak(Title)
        Talker.SpeakAsync(MessageString)

        ' Show Messages for this sub

        MessageBox.Show(MessageString, Title, MessageBoxButtons.OK, MessageBoxIcon.Information)
        Talker.SpeakAsyncCancelAll()
    End Sub

    ' Function to check the letter for the game

    Private Function CheckEnteredLetter(ByVal PassedWord As String, ByVal PassedLetter As String, ByVal PassedMatchedLetterCount As Integer) As Integer

        ' for loop to check that you entered up to 6 letters

        For ndx As Integer = 0 To 5
            If PassedWord(ndx) = PassedLetter Then
                PassedMatchedLetterCount += 1
                Mid(WordMask, ndx + 1) = PassedLetter
            End If
        Next ndx
        Return PassedMatchedLetterCount
    End Function

    ' Public function to get the  random number selected for the game

    Public Function GetRandom(ByVal Min As Integer, ByVal Max As Integer) As Integer

        ' Declare variables

        Dim Generator As System.Random = New System.Random()

        ' Return Generator random value for the game

        Return Generator.Next(Min, Max)
    End Function
End Module
and here's the errors. how to fix. and a better way to do this. and got my Resources folder with the sound effects and the list of radnom letters in a text file. any help.
Severity	Code	Description	Project	File	Line	Suppression State
Message	IDE0059	Value assigned to 'TempMask' is never used	HangMan	E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb	129	Active
Message	IDE0044	Make field readonly	HangMan	E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb	18	Active
Message	IDE0044	Make field readonly	HangMan	E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb	19	Active
Message	IDE0060	Remove unused parameter 'Str'	HangMan	E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb	102	Active
Message	IDE0059	Value assigned to 'EnteredLetter' is never used	HangMan	E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb	123	Active
Message	IDE0059	Value assigned to 'GuessCount' is never used	HangMan	E:\MarvinsFiles\Marvin\Education\DiplomaWebsiteDevelopment\WebSiteDevelopment\Programming\BuildAGraphicalUserInterface\Assignments\AssignmentOne\Programming\HangMan\HangMan\Module1.vb	128	Active

GeneralRe: self talking hangman vb console game tutorial Pin
Dave Kreskowiak31-Jul-19 5:37
mveDave Kreskowiak31-Jul-19 5:37 
GeneralRe: self talking hangman vb console game tutorial Pin
StarTrekCafe31-Jul-19 14:17
memberStarTrekCafe31-Jul-19 14:17 
GeneralRe: self talking hangman vb console game tutorial Pin
Dave Kreskowiak31-Jul-19 16:13
mveDave Kreskowiak31-Jul-19 16:13 
GeneralRe: self talking hangman vb console game tutorial Pin
StarTrekCafe31-Jul-19 16:19
memberStarTrekCafe31-Jul-19 16:19 
GeneralRe: self talking hangman vb console game tutorial Pin
Dave Kreskowiak31-Jul-19 16:23
mveDave Kreskowiak31-Jul-19 16:23 
AnswerRe: self talking hangman vb console game tutorial Pin
ZurdoDev6-Aug-19 10:06
professionalZurdoDev6-Aug-19 10:06 
QuestionMatlab DLL Function is returning nothing !! Pin
Member 1454417528-Jul-19 22:43
memberMember 1454417528-Jul-19 22:43 
QuestionRe: Matlab DLL Function is returning nothing !! Pin
Richard MacCutchan29-Jul-19 4:12
protectorRichard MacCutchan29-Jul-19 4:12 
QuestionVB.NET x Google Maps - best routes Pin
Member 1454069824-Jul-19 18:02
memberMember 1454069824-Jul-19 18:02 
AnswerRe: VB.NET x Google Maps - best routes Pin
Mycroft Holmes24-Jul-19 21:06
memberMycroft Holmes24-Jul-19 21:06 
AnswerRe: VB.NET x Google Maps - best routes Pin
Richard MacCutchan24-Jul-19 21:12
protectorRichard MacCutchan24-Jul-19 21:12 
NewsMessage Closed Pin
19-Jul-19 20:32
memberAbdulrahman Kalari19-Jul-19 20:32 
QuestionOutOfMemoryException in VB.Net Pin
DTGeek19-Jul-19 6:48
memberDTGeek19-Jul-19 6:48 
AnswerRe: OutOfMemoryException in VB.Net Pin
Gerry Schmitz19-Jul-19 12:06
mveGerry Schmitz19-Jul-19 12:06 
GeneralRe: OutOfMemoryException in VB.Net Pin
DTGeek23-Jul-19 5:14
memberDTGeek23-Jul-19 5:14 
GeneralRe: OutOfMemoryException in VB.Net Pin
DTGeek30-Jul-19 4:59
memberDTGeek30-Jul-19 4:59 
Questioncontextmenu when 2 files are selected Pin
JR21218-Jul-19 1:58
memberJR21218-Jul-19 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.