deepender singla

deepender singla

  • NA
  • 113
  • 76.4k

String Formation

Jul 26 2011 7:10 AM
Respected Members

Hi, first of all i must thanku all my fellow members for helping me so much in my problems, the help which i never expected this is my first experience with visual studio and because of you all u make it so easy and a fun to learn , i will soon learn more c# and start addressing question here , but till that time i request u to plz co-operate with me as i am still a learner and will always be ,

now i should stop posting a emotional movie script here and ask my doubt so here it is , i am struck on this i have this code:

using Microsoft.VisualBasic;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Speech.Recognition


using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }


        private void Form1_Load(object sender, EventArgs e)
        {
            // Create a new SpeechRecognizer instance.
            sr = new SpeechRecognizer()



            // Create a simple grammar that recognizes "red", "green", or "blue".
            Choices colors = new Choices();
            colors.Add("red");
            colors.Add("green");
            colors.Add("blue");
            colors.Add("white");




            GrammarBuilder gb = new GrammarBuilder();
            gb.Append(colors);




            // Create the actual Grammar instance, and then load it into the speech recognizer.
            Grammar g = new Grammar(gb);
            sr.LoadGrammar(g);




            // Register a handler for the SpeechRecognized event.
            sr.SpeechRecognized += new EventHandler<SpeechRecognizedEventArgs>(sr_SpeechRecognized);
        }




        // Simple handler for the SpeechRecognized event.
        private void sr_SpeechRecognized(object sender, SpeechRecognizedEventArgs e)
        {
            if(e.Result.Text=="Red");
            MessageBox.Show(e.Result.Text);
        }




        private SpeechRecognizer sr;
 


Now in my application i need to judge numbers 1 to 6 that is when user say number 3 than it should in a string like this ("#3");

Now after this user again speaks something from 500, 1500, 2500 and it advances the previous string to this if he say 1500
("#3 P1500);

This is what i really want , i will add this 1to 6 and 500, 1500, 2500 to my grammar , thats i know but i dont know how after one if detected my system will again look for another work i dont have much knowledge with stirngs also plz help me with that also,

Once again i am a starter so i request you to a give a detail solution.


Thanks in advance








Answers (18)