Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

The name 'send' does not exist in the current context


  • Please log in to reply

#1
ryang96

ryang96

    Member

  • Member
  • PipPip
  • 79 posts
hi, i'm a newbie at programing and im trying to make a simple program that you can type something into and it will repeat it. However everywhere i wrote send, it gives me an error that it doesn't exist in the current context. can anyone help me resolve my problem?
[codebox]using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
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 button1_Click(object sender, EventArgs e)
{
if (textBox2.Equals(""))
return;
Thread thread = new Thread(SendText);
thread.Start();
}
private void SendText()
{
String text = textBox2.Text;
send = true;
while (send)
{
SendKeys.SendWait(text);
SendKeys.SendWait("{ENTER}");
System.Threading.Thread.Sleep(1000);
}
}
private void button2_Click(object sender, EventArgs e)
{
Send = false;
}
}
}[/codebox]
  • 0

Advertisements


#2
ThatGuy1107

ThatGuy1107

    New Member

  • Member
  • Pip
  • 1 posts
You never declared 'send' as a variable in this program. At one point you set the value, but it was never initialized.

public partial class Form1 : Form
{
private bool send; //Add this!
public Form1()
{
...the rest of your code
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP