Link to home
Start Free TrialLog in
Avatar of GlobaLevel
GlobaLevelFlag for United States of America

asked on

ERROR: The name 'textbox1' does not exist in the current context

I ma trying this simple  program in Visual Studio 2005, however I get this error...here is my code:

public static void main(String[] args)
        {
            int txtbox1;
            string[] w = new string[3];
            w[0] = "Hello";
            w[1] = ",";
            w[3] = "world";
            for (int i = 0; i < 3; i++)
                textbox1.Text = w.ToString();
        }
ASKER CERTIFIED SOLUTION
Avatar of TechSinger
TechSinger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of GlobaLevel

ASKER

I tried the snippet of code provided it still thru me any error:

Error      1      An object reference is required for the nonstatic field, method, or property
Error      2      Cannot convert type 'string' to 'System.Windows.Forms.TextBox'      
Error      3      Cannot implicitly convert type 'string' to 'System.Windows.Forms.TextBox'      C:\Visual Studio 2005 10-08\WindowsApplication1\Form1.cs      34      28      WindowsApplication1

public static void main(String[] args)
        {
            string txtbox1;
            string[] w = new string[3];
            w[0] = "Hello";
            w[1] = ",";
            w[3] = "world";
            for (int i = 0; i < 3; i++)
                textBox1+= w[i].ToString();
        }



I tried the following but an error:
Class, struct, or interface method must have a return type

Here is my code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

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

        private  void button1_Click(object sender, EventArgs e)
        {
           
        }
       

        public static main(String[] args)
        {
           
            string[] w = new string[3];
            w[0] = "Hello";
            w[1] = ",";
            w[3] = "world";
            for (int i = 0; i < 3; i++)
                return textBox1 = w[i].ToString;
               
        }
    }



}


On the form there is a textbox called: textBox1
There is a button called: button1

The goal is to write a simple program that will print out hello, world through an array
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks!
I had this error "The name 'textBoxFind' does not exist in the current context" was caused because I inadvertently toggled textBoxFind.GenerateMember to false in the Properties wind in VS at some point.  Switched it back to true.  Hope that helps anyone else looking at similar error.