tags:

views:

92

answers:

2

I am looking to create a simple project but its turning out not to be so simple. The project I am trying to do is. If textboxA is a persons name, then I want to excute textboxB/10 and display the results in the label box on the form.

I try to code the button

for textboxA = Andrea
    Then (labelA.text = textBoxB/10)

I am not able to compile the program because of the errors I get. Any help would be great.

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;

namespace Assignment2_White
{
    public partial class Form1 : Form
    {
        public Form1()
        {    
            String Andrea;
            String A = Andrea;

            InitializeComponent();
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
           for textBox1= A;
              label4.text = textBox2 / 10;
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            String Andrea;
            String A = Andrea;
        }

        private void textBox2_TextChanged(object sender, EventArgs e)
        {

        }
    }
}
+7  A: 

Edit: Looking at the code above, I think it best to start with a beginners book or tutorial. This would be a good start: http://www.csharp-station.com/Tutorials/Lesson01.aspx


If your code is like your description, then the problem lies within:

if (textboxA.Text == "Andrea")
{
    labelA.Text = Convert.ToInt32(textBoxB.Text) / 10;
}

This is simplified and guessing at your code (not to mention no error checking), but it should guide you to a solution.

In VB.NET, just in case:

If textboxA.Text = "Andrea" Then
    labelA.Text = Convert.ToInt32(textBoxB.Text) / 10
End If
Kyle Rozendo
A: 
private void button1_Click(object sender, EventArgs e) 
{ 
    if(textBox1.Text == A)
    {
        label4.Text = (Convert.ToDouble(textBox2.Text) / 10).ToString(); 
    }
} 
Brissles
Error 1 Cannot implicitly convert type 'string' to 'System.Windows.Forms.Label'
randywhite30