15,917,005 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10274631 (Top 5 by date)
Member 10274631
20-Sep-13 0:35am
View
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
double a, b, r; // to represent textboxes
string result = textBox4.Text.ToString(); // to represent the result
string Operation = textBox2.Text.ToString(); // to represent the operation
{
switch (Operation)
{
case "+":
a = double.Parse(textBox1.Text); // input string incorrect format
b = double.Parse(textBox3.Text); // if I leave blank
r = a + b;
textBox4.Text = r.ToString();
break;
case "-":
a = double.Parse(textBox1.Text);
b = double.Parse(textBox3.Text);
r = a - b;
textBox4.Text = r.ToString();
break;
case "*":
a = double.Parse(textBox1.Text);
b = double.Parse(textBox3.Text);
r = a * b;
textBox4.Text = r.ToString();
break;
case "/":
a = double.Parse(textBox1.Text);
b = double.Parse(textBox3.Text);
r = a / b;
textBox4.Text = r.ToString();
break;
default: // if the user input a value not in the operation.
textBox4.Text = "Cannot compute";
break;
}
if (String.IsNullOrEmpty(textBox1.Text)) // if user input nothing in textBox2
{
label6.Text = "Please enter the first number"; // label7 should appear this text.
}
if (String.IsNullOrEmpty(textBox2.Text)) // if user input nothing in textBox2
{
label7.Text = "Please enter an operator"; // label7 should appear this text.
}
if (String.IsNullOrEmpty(textBox3.Text)) // if user input nothing in textBox2
{
label8.Text = "Please enter the secong number"; // label7 should appear this text.
}
{
}
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
textBox1.Text = textBox1.Text.ToString();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void textBox3_TextChanged(object sender, EventArgs e)
{
textBox3.Text = textBox3.Text.ToString();
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
textBox4.Text = textBox4.Text.ToString();
}
private void label6_Click(object sender, EventArgs e)
{
}
}
}
a = double.Parse(textBox1.Text); // if I leave blank textbox1 incorrect input
b = double.Parse(textBox3.Text); // same in textbox3 leave blank incorrect input.
What I did wrong here?
Member 10274631
15-Sep-13 11:50am
View
I follow your instruction
Here is my revise code
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
string strReplace = textBox2.Text;
}
private void button1_Click(object sender, EventArgs e)
{
string Replace = strReplace;
if (textBox1.Text.Contains(textBox2.Text))
{
textBox3.Text = "" + textBox1.Text.Replace(strReplace, string.Empty).ToUpper();
}
else
{
textBox3.Text = "I cannot subtract the word "";
}
textBox3.Text = textBox1.Text.Replace(textBox2.Text, "").ToUpper();
textBox4.Text = textBox1.Text.Replace(textBox2.Text, "").ToLower();
textBox5.Text = textBox1.Text.Length.ToString();
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
It subtract the word in textbox2 that match in textbox1 but it will not show if the word was not match, "I cannot subtract the word "(user typed word in textbox2)" // it suppose to catch the word that user type in the parenthesis. It means else is not working. I am not suppose to use Unicode.
A little bit more of your help and I will be done on this one.
Thank you.
Member 10274631
15-Sep-13 1:17am
View
This is a test (textbox1)
is a (textbox2)
THIS TEST (textbox3)
this test (textbox4)
This is a test (textbox1)
apple (textbox2)
I cannot subtract the word <apple> (textbox3)//this is the error that need to show if the word was not found on textbox1.
this test (textbox4)
Again, thank you for your help.
Member 10274631
15-Sep-13 1:12am
View
if the word/s can be found on textbox1 it must be sutracted and will show the remaining words in textbox3 and 4.
Member 10274631
15-Sep-13 1:03am
View
Bill I will not post my problem here if I know how to start the if statement on this case. Yes I know how to put the text in upper and lower case.