• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

vb.net events not firing

Joined
Dec 22, 2007
Messages
184 (0.05/day)
Likes
7
Location
Central Nebraska
System Name CORSAIR
Processor AMD Phenom 1090T x6 @3.2
Motherboard Gigabyte Ga-78LMT-S2P
Cooling High efficiency dust cooling
Memory 8GB GSkill DDR3 1333
Video Card(s) Sapphire Radeon HD3870 512MB GDDR4 PCI-e toxic
Storage Seagate SV35.3 ST3250310SV 250GB SATAII(Windows 7 Pro x64), 320GB Samsung SATAII(Storage and SuSE)
Display(s) Dell 20" LCD, Dell 17" LCD
Power Supply Antec Cool Blue 650W Modular
Software Windows 7 Professional SP1, Visual Studio 2010 Ultimate
#1
Ive created an event in my code, however the sub I created to handle the event is not firing - any ideas o nthe code below?

Code:
Imports System.Speech.Recognition
Public Class Form1

    Public Shared Recognizer As SpeechRecognizer
    Public Event LoadGrammarCompleted As EventHandler(Of LoadGrammarCompletedEventArgs)

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Recognizer = New SpeechRecognizer
        Dim dictation As Grammar = New DictationGrammar
        Recognizer.LoadGrammar(dictation)

    End Sub
    Public Sub LoadGrammar(ByVal sender As Object, ByVal e As LoadGrammarCompletedEventArgs) Handles MyClass.LoadGrammarCompleted
        MessageBox.Show("Bing!")
    End Sub

End Class
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
21,058 (6.22/day)
Likes
10,182
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#2
Last edited:
Joined
Dec 22, 2007
Messages
184 (0.05/day)
Likes
7
Location
Central Nebraska
System Name CORSAIR
Processor AMD Phenom 1090T x6 @3.2
Motherboard Gigabyte Ga-78LMT-S2P
Cooling High efficiency dust cooling
Memory 8GB GSkill DDR3 1333
Video Card(s) Sapphire Radeon HD3870 512MB GDDR4 PCI-e toxic
Storage Seagate SV35.3 ST3250310SV 250GB SATAII(Windows 7 Pro x64), 320GB Samsung SATAII(Storage and SuSE)
Display(s) Dell 20" LCD, Dell 17" LCD
Power Supply Antec Cool Blue 650W Modular
Software Windows 7 Professional SP1, Visual Studio 2010 Ultimate
#3
loadgrammarcompleted looks for sender as obect and e as system.speech.recognition.loadgrammarcompletedeventargs

I cant find what it's looing for. Ive tried me, e and get an error saying "Unable to cast object of type 'system.eventargs' to type 'system.speech.recognition.loadgrammarcompletedeventargs.'"
 

FordGT90Concept

"I go fast!1!11!1!"
Joined
Oct 13, 2008
Messages
21,058 (6.22/day)
Likes
10,182
Location
IA, USA
System Name BY-2015
Processor Intel Core i7-6700K (4 x 4.00 GHz) w/ HT and Turbo on
Motherboard MSI Z170A GAMING M7
Cooling Scythe Kotetsu
Memory 2 x Kingston HyperX DDR4-2133 8 GiB
Video Card(s) PowerColor PCS+ 390 8 GiB DVI + HDMI
Storage Crucial MX300 275 GB, Seagate 6 TB 7200 RPM
Display(s) Samsung SyncMaster T240 24" LCD (1920x1200 HDMI) + Samsung SyncMaster 906BW 19" LCD (1440x900 DVI)
Case Coolermaster HAF 932 w/ USB 3.0 5.25" bay
Audio Device(s) Realtek Onboard, Micca OriGen+
Power Supply Enermax Platimax 850w
Mouse SteelSeries Sensei RAW
Keyboard Tesoro Excalibur
Software Windows 10 Pro 64-bit
Benchmark Scores Faster than the tortoise; slower than the hare.
#4
You have to call New LoadGrammarCompletedEventArgs() most likely and make sure to give it what it requires.

I don't know what code you're working with but perhaps you aren't supposed to raise the event at all, it does. You just need to start whatever process in that library that would raise it (a .Start() or something).

Also, the Recognition code should have the event, not your form. Your form needs to hook into its event, not create a new one.