Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7740073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:40:53+00:00 2026-06-01T08:40:53+00:00

I have 2 forms set up. In the first form I have the following

  • 0

I have 2 forms set up. In the first form I have the following code.

frm_BL addBranch = new frm_BL();

do
{
    addBranch.ShowDialog();
    if (addBranch.txtAmount.Text == "")
    {
        break;
    }

} while (true);

In the main form. And just this in the second form.

private void btnAccept_Click(object sender, EventArgs e)
{
    this.Close();
}

However I found that if I change the code of the main form to:

 if (addBranch.txtAmount.Text == null) //changed to null

The second form keeps popping up. But if it stays at

if (addBranch.txtAmount.Text == "") 

It closes the form. Can someone explain why that is?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T08:40:55+00:00Added an answer on June 1, 2026 at 8:40 am

    The best way to do this is:

    if (String.IsNullOrEmpty(addBranch.txtAmount.Text))
    

    The txtAmount.Text property is a string containing the content of the textbox. If the textbox is empty then it’s a zero-length string.

    Checking for equality with null is saying “If the textbox doesn’t have a string …”, which will always be false. The correct condition to check is “If the textbox’s string is empty …”.

    Using the IsNullOrEmpty method checks for both conditions. In this case the string should never be null, but it doesn’t hurt to check.

    Note that "" is an empty string (equivalent to String.Empty), whereas null says the string doesn’t exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am stumped by the following code: <b><i>First name *</b></i> : <input type=text name='<?php
I have the following code: class UserForm(ModelForm): email = forms.EmailField(widget = forms.TextInput(attrs ={ 'id':'email'}),
I have a website with several forms that all pass the same set of
How should I set WordWrap = false to a System.Windows.Forms.Label ? I have a
I have a ListView control on my form set up like this in details
Okay, so I have this form that is set to preload a DB record
I have set the form decorators in this way: <?php $this->setElementDecorators(array( 'Label', array(array('labelTd' =>
I have a parent form that is set to be TopMost and then I
I have a form whose action is set to itself. I want it this
I have a form that contains dataGridView, whose coloumn are set to dgrv1.Width =dgrv1.Columns.GetColumnsWidth(DataGridViewElementStates.Visible)+20;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.