Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27336

VS 2010 What is this error?? :\ I can't seem to fix it.

$
0
0
ERROR:


Code:

System.InvalidOperationException was unhandled
  Message=An error occurred creating the form. See Exception.InnerException for details.  The error is: 'phrase' cannot be an empty string.
Parameter name: phrase
  Source=LE21 - Voice Recognition
  StackTrace:
      at LE21VoiceRecognition.My.MyProject.MyForms.Create__Instance__[T](T Instance) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 190
      at LE21VoiceRecognition.My.MyProject.MyForms.get_Form3()
      at LE21VoiceRecognition.My.MyApplication.OnCreateMainForm() in C:\Users\Chao Lee\Desktop\WindowsApplication2\WindowsApplication2\My Project\Application.Designer.vb:line 35
      at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
      at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
      at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
      at LE21VoiceRecognition.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81
      at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
      at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
      at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
      at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
      at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
      at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.ArgumentException
      Message='phrase' cannot be an empty string.
Parameter name: phrase
      Source=System.Speech
      ParamName=phrase
      StackTrace:
            at System.Speech.Internal.Helpers.ThrowIfEmptyOrNull(String s, String paramName)
            at System.Speech.Recognition.Choices.Add(String[] phrases)
            at System.Speech.Recognition.Choices..ctor(String[] phrases)
            at LE21VoiceRecognition.Form3..ctor() in C:\Users\Chao Lee\Desktop\WindowsApplication2\WindowsApplication2\Form3.vb:line 24
      InnerException:



CODE:

Code:

Imports System.Speech.Recognition
Imports System.Speech.Recognition.SrgsGrammar
Imports System.Net.Mail
'Credits to http://idealprogrammer.com and http://www.microsoft.com and me for putting this app together :D

Public Class Form3

    'This object represents the Speech recognition engine
    Private recognizer As SpeechRecognizer

    Public Sub New()

        InitializeComponent() ' This call is required by the Windows Form Designer.

        recognizer = New SpeechRecognizer() ' Add any initialization after the InitializeComponent() call.


        AddHandler recognizer.SpeechRecognized, AddressOf recognizer_SpeechRecognized 'this is raised when the application correctly recognizes spoken words


        'The rule is that each choice in the first Append method can be combined with each word specified
        'in the second method.
        Dim grammar As New GrammarBuilder()
        grammar.Append(New Choices(System.IO.File.ReadAllLines("Commands.txt")))


        'A grammar must be loaded into the engine. This is possible by loading an object or an xml file
        recognizer.LoadGrammar(New Grammar(grammar))
    End Sub

    Private Sub recognizer_SpeechRecognized(ByVal sender As Object, ByVal e As SpeechRecognizedEventArgs)
 
        Dim NEURO = CreateObject("sapi.spvoice")
        Select Case e.Result.Text.ToUpper
            Case Is = "SEND EMAIL"
                'The Line Just Above Lets The Program/App Know That A Login Will Need The Email & Password To Log In


            Case Is = "CLOSE EMAIL"
                Me.Close()

                End
        End Select


    End Sub

    Private Sub GhostTheme1_Click(sender As System.Object, e As System.EventArgs) Handles GhostTheme1.Click

    End Sub

    Private Sub Label2_Click(sender As System.Object, e As System.EventArgs) Handles Label2.Click
        Label2.Text = ("")
    End Sub

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim NEURO = CreateObject("sapi.spvoice")
        Dim mail As New MailMessage()
        Dim SmtpServer As New SmtpClient
        SmtpServer.EnableSsl = True
        SmtpServer.Host = "smtp.gmail.com"
        SmtpServer.Port = 587 'Tells The Program/App What Port To Use
        SmtpServer.Credentials = New System.Net.NetworkCredential(EmailTB.Text, PasswordTB.Text)
        'The Line Just Above Lets The Program/App Know That A Login Will Need The Email & Password To Log In
        mail.From = New MailAddress(EmailTB.Text) 'This Uses The "EmailTB.Text" To Set The "From" In The Email
        mail.To.Add(ToTB.Text) 'This Uses The "ToTB.Text" To Set As The Person That Will Recieve The Email
        mail.Subject = (SubjectTB.Text) 'This Uses The "SubjectTB.Text" To Set The Subject Of The Email
        mail.Body = (MessageTB.Text)
        SmtpServer.Send(mail) 'Sends The Email
        NEURO.Speak("Your message has been sent, sir.")
        Label2.Text = ("Your message has been sent")
    End Sub
End Class


Viewing all articles
Browse latest Browse all 27336

Trending Articles