473,325 Members | 2,771 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

getting error like cannot implicitly convert type string to bool

Private void butten1.click(object sender,eventArgs e) { if(textBox1.Text="admin") { if(textbox2.text="password"){ form2 f2=new form(); form2.show();} else{ messagebox.show("incorrect password");} while i am run this code i get the error like cannot implicitly convert type string into bool.
May 25 '15 #1
1 1950
computerfox
276 100+
First off, please use the code tags

Second:
Expand|Select|Wrap|Line Numbers
  1. Private void butten1.click(object sender,eventArgs e) { 
  2.  if(textBox1.Text="admin") {
  3.   if(textbox2.text="password"){ 
  4.    form2 f2=new form(); 
  5.    form2.show();
  6.   } 
  7.   else{ 
  8.    messagebox.show("incorrect password");
  9.   }
  10. }
  11.  
Should be:
Expand|Select|Wrap|Line Numbers
  1. Private void butten1.click(object sender,eventArgs e) { 
  2.  if(textBox1.Text=="admin") {
  3.   if(textbox2.text=="password"){ 
  4.    form2 f2=new form(); 
  5.    form2.show();
  6.   } 
  7.   else{ 
  8.    messagebox.show("Incorrect password");
  9.   }
  10. }
  11.  
You can also shorten it a bit with:
Expand|Select|Wrap|Line Numbers
  1. Private void butten1.click(object sender,eventArgs e) { 
  2.  if(textBox1.Text=="admin" && textbox2.text=="password") {
  3.    form2 f2=new form(); 
  4.    form2.show();
  5.   }
  6.   else{ 
  7.    messagebox.show("Incorrect password");
  8.   }
  9. }
  10.  

Hope that helps!
May 25 '15 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: juli | last post by:
I declared: public delegate void PaintEventHandler(object objSender,PaintEventArgs pea); and this.Paint+=new PaintEventHandler(MyPaintHandler); and the: static void MyPaintHandler(object...
2
by: Jeff | last post by:
I get the following error: Cannot implicitly convert type 'Factory.Stack.pArrayStack' to 'Factory.Stack.StackDefs.ImStack' at compile time. I thought perhaps there was a mismatch between the...
2
by: Patrick Olurotimi Ige | last post by:
When i convert:- this code from VB to C# Why do i get error "Cannot implicitly convert type 'object' to 'bool' VB --- If cmdcommand.Parameters("ReturnValue").Value = 1 Then lblStatus.Text =...
6
by: eric.goforth | last post by:
What's wrong with this? if (bool)(UserIDs == ThisUserId) { return true; }
1
by: rmrao | last post by:
protected override void InitializeCulture() { string culture = ""; culture = Request.QueryString; if (culture = null) culture = "en-US"; ...
3
by: sappyjosh | last post by:
public void Update_Stock(Inseed Is) { if (con.State == ConnectionState.Open) { con.Close(); } try { ...
2
by: vadiraj hebbar | last post by:
public static double reversenumber(double i) { i = 1 * i; if (i < 0) return i.ToString() + "is reverse number"; else if...
4
by: Asma P | last post by:
//declare variable internal bool CheckBox11 = false; if (!string.IsNullOrEmpty(Reader.ToString())) { CheckBoxID = Reader.ToString(); ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.