1
Answer

problem need help

david green

david green

15y
2.1k
1
this is code to make a program that when the name of an animal is spoken into a mic a picture of that animal is displayed that is the function i am having bother with here is the code it is the switch statement i am having bother with if you could replace the ? also any other suggestions would be helpfull

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SpeechLib;
namespace SimpleSpeechRecognition
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{


speechListBox1.Items.Add("dog");
speechListBox1.Items.Add("cat");
speechListBox1.Items.Add("hamster");
speechListBox1.Items.Add("elephant");
speechListBox1.Items.Add("lion");
speechListBox1.Items.Add("tiger");
speechListBox1.SpeechEnabled = true;
}

private void speechListBox1_SelectedIndexChanged(obje... sender, EventArgs e)
{
MessageBox.Show(speechListBox1.SelectedI...
SayPhrase(speechListBox1.SelectedItems[0...
}


private void SayPhrase(string PhraseToSay )
{

SpeechVoiceSpeakFlags SpFlags = new SpeechVoiceSpeakFlags();
SpVoice Voice = new SpVoice();
Voice.Speak(PhraseToSay, SpFlags);

}



private void pictureBox1_click(object sender, EventArgs e)
{
switch (?)
{


case "cat":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\cat.jpg");
pictureBox1.Refresh();
}
case "dog":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\dog.jpg");
pictureBox1.Refresh();
}
case "hamster":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\hamster.jpg");
pictureBox1.Refresh();
}
case "elephant":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\elephant.jpg");
pictureBox1.Refresh();
}
case "lion":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\lion.jpg");
pictureBox1.Refresh();
}
case "tiger":
{
pictureBox1.Image = Image.FromFile(@"C:\Documents and Settings\Administrator\My Documents\My Pictures\pictures\tiger.jpg");
pictureBox1.Refresh();
}
}

}




}
}
Answers (1)