Events in C# sending string to other functions

This is a discussion on Events in C# sending string to other functions within the C# Programming forums, part of the General Programming Boards category; So I have a C# program that take the user input and sends it out to another function. The problem ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    52

    Events in C# sending string to other functions

    So I have a C# program that take the user input and sends it out to another function.
    The problem I'm having is that it only works the first time I click on button1, then I have to re-run the program so I can send out anything else.

    I'm not sure what's the problem here.

    Code:
     
    
            public Form1()
            {
                int i;
                InitializeComponent();
                InitComPort1();
                readDevice();
                i = ReadDevice();
                textBox3.Text = ReadString(2);
    
                }
    
    private void button1_Click_1(object sender, EventArgs e)
            {
                int i;
                string DS = "DS";
                string DS_Rev = textBox2.Text;
                string DS_SN = textBox1.Text;
                string DS_Type = comboBox1.Text;
                string DS_Pdate = DateTime.Now.ToString("MMyy");
                i = ProgramDevice(3, DS + DS_SN + DS_Type, DS_Pdate + DS_Rev);
                if (i == 1)
                {
                    MessageBox.Show(DS + DS_SN + DS_Type + DS_Pdate + DS_Rev + " Programmed Succesfully", "Programmer Result"); 
                }

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    My guess is that it's getting hung up in ProgramDevice() the second time you click the button. You can try throwing up another MessageBox right before the call to ProgramDevice() to see if it's getting there.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Put a breakpoint right before ProgramDevice is called. Once it hits the breakpoint step into ProgramDevice and see if it ever returns.

    Incidentally you can enable line numbers in MSVS which helps when debugging. I find that without line numbers being shown it is difficult to tell at a glance where my breakpoints are.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polymorphism and generic lists
    By Shibby3 in forum C# Programming
    Replies: 9
    Last Post: 07-26-2010, 06:27 AM
  2. Replies: 8
    Last Post: 04-25-2008, 03:45 PM
  3. Message class ** Need help befor 12am tonight**
    By TransformedBG in forum C++ Programming
    Replies: 1
    Last Post: 11-29-2006, 11:03 PM
  4. Reverse a string (without using any string functions?)
    By geetard in forum C Programming
    Replies: 2
    Last Post: 11-15-2006, 07:42 PM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21