vb dot net imports errors

  • (2 Pages)
  • +
  • 1
  • 2

16 Replies - 752 Views - Last Post: 15 July 2019 - 05:34 PM Rate Topic: -----

#1 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

vb dot net imports errors

Posted 06 July 2019 - 04:04 AM

hi. using the jaws for windows screen reader from http://www.freedomscientific.com. and using visual studio community 2019 , 32 bit, on a assus laptop running windows 10 64 bit home 1903. so, just rebuilding a text to speech hangman game, and code it, from a previous project a few years back, and was getting a null error, when i tried to run the installed program. so created the console, copied and pasted the files for the word list and also the wav files. now will paste below. getting errors. how do i fix these, to do with imports, have tried googling, but could not seem to find any answers to fix my issues. not to do it, but where am i going wrong. will paste the error list below and in australia.

marvin.

ps: pasting the error list below.

Severity Code Description Project File Line Suppression State
Error BC30002 Type 'SpeechSynthesizer' is not defined. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 21 Active
Error BC30002 Type 'SpeechSynthesizer' is not defined. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 28 Active
Error BC30451 'Application' is not declared. It may be inaccessible due to its protection level. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 33 Active
Error BC30451 'SynhesisMediaType' is not declared. It may be inaccessible due to its protection level. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 47 Active
Error BC30451 'Application' is not declared. It may be inaccessible due to its protection level. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 121 Active
Error BC30451 'MessageBox' is not declared. It may be inaccessible due to its protection level. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 197 Active
Error BC30451 'MessageBoxButtons' is not declared. It may be inaccessible due to its protection level. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 197 Active
Error BC30451 'MessageBoxIcon' is not declared. It may be inaccessible due to its protection level. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 197 Active
Warning BC40056 Namespace or type specified in the Imports 'System.Speech.Synthesis' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 6 Active
Warning BC40056 Namespace or type specified in the Imports 'System.Windows.Forms' doesn't contain any public member or cannot be found. Make sure the namespace or the type is defined and contains at least one public member. Make sure the imported element name doesn't use any aliases. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 7 Active
Warning BC42030 Variable 'NewUri' is passed by reference before it has been assigned a value. A null reference exception could result at runtime. HangMan C:\Users\Owner\Desktop\HangMan\HangMan\Module1.vb 44 Active

Is This A Good Question/Topic? 0
  • +

Replies To: vb dot net imports errors

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,181
  • Joined: 12-June 08

Re: vb dot net imports errors

Posted 06 July 2019 - 04:34 AM

Can you copy/paste your code here?
Was This Post Helpful? 0
  • +
  • -

#3 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

Re: vb dot net imports errors

Posted 06 July 2019 - 11:25 PM

hi. here's my code. how to fix the errors, and the imports and the talker function if not used and also how to select more voices and also how to info. thanks. pasting below. marvin. ps: pasting below.

Imports System
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()

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

        ' 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
        Dim Result As Boolean = Uri.TryCreate(Directory.GetParent(Directory.GetCurrentDirectory).Parent.ToString + "\en-sc", UriKind.Absolute, NewUri)

        If Result Then
            Talker.AddLexicon(NewUri, SynhesisMediaType.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)

        ' 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("BugleReveille.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 PassedMatcheLetterCount 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
                PassedMatcheLetterCount += 1
                Mid(WordMask, ndx + 1) = PassedLetter
            End If
        Next ndx
        Return PassedMatcheLetterCount
    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
:code:

This post has been edited by modi123_1: 07 July 2019 - 08:00 AM
Reason for edit:: In the future please use the [code] tag button in the editor

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,181
  • Joined: 12-June 08

Re: vb dot net imports errors

Posted 07 July 2019 - 08:10 AM

A few things.

First this needs to be in a windows form. You have a host of errors crop up because it's not, but in a console app.

Second - you need to add the right reference. Right click 'reference' -> add reference -> assemblies -> system.speech

Third - your 'RenderMask' function needs a return type. Most likely an 'as string'

Fourth - (and this is part of the previous) you should have options for strict and explicit on. There are a handful of issues that need to be addressed (the function return type, a cast, etc).

Menu -> tools -> projects and solutions -> vb defaults
Turn 'on' option explicit and option strict.
Was This Post Helpful? 0
  • +
  • -

#5 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

Re: vb dot net imports errors

Posted 07 July 2019 - 04:42 PM

hi. well it is a console app. so do i remove the windows forms, and how to then cast and return, got a code sample, and will try and fix the other things. it is a console app. when i did a web design course about 7 years ago and was a console app, part of the programming assignment, for the web design course. so, do i need to take out the windows forms, and it is a console app, not a windows forms app. so, any suggestions. marvin.ps: will try to fix the other issues.
Was This Post Helpful? 0
  • +
  • -

#6 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

Re: vb dot net imports errors

Posted 07 July 2019 - 05:25 PM

hi, cannot find that option, in visual studio 2019 community 32. where is it, when i go to the tools, cannot hear the projects and solutions. do i search for that. help.

hi, found it the solutions and vb defaults, had to search in options. so turned option on on and option strict on. now, just how to fix the cast, and do i remove the system.windows.forms, this is a console app. marvin.and also added the system.speech.

hi. how do i fix the rest of these, and maybe some code samples, and then to remove. will post below. if you can help. thanks. not to do it for me, but to help me figure out and how to fix, thanks. been a few years since i did vb console app. a bit rusty. will paste below. HangMan - Microsoft Visual Studio
Applicationndows Setti Application page:
Compileionndows Setti
Configuration: N/A Platform: N/ADebugileionndows Setti
Referencesnndows Setti Assembly name: Root namespace:Resourcessnndows Setti HangMan HangMan
Servicesessnndows Setti Target framework: Application type:Settingsessnndows Setti .NET Framework 4.7.2 Console Application
Signing essnndows Setti
Auto-generate binding redirectsMy Extensionsows Setti
Startup object: Icon:Securitynsionsows Setti Module1 (Default Icon)Publishynsionsows Setti
Code Analysis ows Setti Assembly Information... View Windows Settings
Enable application framework HangMan Project Properties
Project File HangMan.vbproj
Project Folder C:\Users\Owner\De
Project File
The name of the file containing
build, configuration, and other inf...
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,181
  • Joined: 12-June 08

Re: vb dot net imports errors

Posted 07 July 2019 - 05:29 PM

Pretty certain that was _not_ a console app originally. Too many references to winform things.
Was This Post Helpful? 0
  • +
  • -

#8 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

Re: vb dot net imports errors

Posted 07 July 2019 - 05:45 PM

hi, so how to fix that, do i take out the win forms reference and also the new uri, and other variables an how to fix the cast, did paste the new list of errors. thanks.
Was This Post Helpful? 0
  • +
  • -

#9 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,181
  • Joined: 12-June 08

Re: vb dot net imports errors

Posted 07 July 2019 - 08:38 PM

I don't understand what you wrote.
Was This Post Helpful? 0
  • +
  • -

#10 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

Re: vb dot net imports errors

Posted 08 July 2019 - 02:05 AM

hi, sorry, so should i take out the windows forms reference, and is there a way to code the uri query, and how to do that, and also the other errors, how to fix, like the variable never being used. can you let me know and also how to cast and return what for one variable. able to help. how to fix. marvin.
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,181
  • Joined: 12-June 08

Re: vb dot net imports errors

Posted 08 July 2019 - 07:00 AM

sure.. take them out.

Is the 'uri' bit even needed? If not take it out.

If a variable is not being used then comment it out.

Casting is a pretty easy thing to work on. Try puzzling that one out.
Was This Post Helpful? 0
  • +
  • -

#12 BlindBuddy54   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 06-July 19

Re: vb dot net imports errors

Posted 15 July 2019 - 04:12 AM

hi, a screen reader user, totally blind and using jaws for windows. works great with visual studio 2019 community. now, when i try to run my console hangman game, supposed to be a self talking game with sound effects, says cannot find part of the directory or files, and have debugged, and no errors, and cannot seem to find an answer. any ideas. how to get this to work, so it starts talking, unless there's any self talking hangman games, where you have 13 turns to then search for a correct 6 letter word from a list of words from a file. marvin in australia.
Was This Post Helpful? 0
  • +
  • -

#13 astonecipher   User is offline

  • Senior Systems Engineer
  • member icon

Reputation: 2942
  • View blog
  • Posts: 11,425
  • Joined: 03-December 12

Re: vb dot net imports errors

Posted 15 July 2019 - 05:08 AM

Language? Throw a break point before it looks for the files and see where it is looking. If that is correct and it still can't find them, check the permissions on the directory that program can read it.
Was This Post Helpful? 0
  • +
  • -

#14 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7056
  • View blog
  • Posts: 23,989
  • Joined: 05-May 12

Re: vb dot net imports errors

Posted 15 July 2019 - 05:49 AM

Does it work correctly when running outside of the IDE (as opposed to launched by Visual Studio)?

Also what was the previous version of Visual Studio you last used prior to VS2019? There was a change in the default running directory around VS2017 or VS2017, I think.
Was This Post Helpful? 0
  • +
  • -

#15 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15262
  • View blog
  • Posts: 61,181
  • Joined: 12-June 08

Re: vb dot net imports errors

Posted 15 July 2019 - 07:03 AM

Merging with existing thread.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2