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 8952959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:59:21+00:00 2026-06-15T13:59:21+00:00

I currently have an WinForm consisting of Name, Address, Zip Code, State, and Age.

  • 0

I currently have an WinForm consisting of Name, Address, Zip Code, State, and Age.

Once the user inputs the data, they click the “Exit” button which confirms no fields are blank, then saves the data to a file. I want to add a Zip Code validation that confirms the textbox (ZipField) contains only numbers.

    private void Btn_Click(object sender, EventArgs e)
    {

        if (String.IsNullOrEmpty(NField.Text) || String.IsNullOrEmpty(AField.Text) ||
            String.IsNullOrEmpty(ZField.Text) || String.IsNullOrEmpty(SField.Text) ||
            String.IsNullOrEmpty(AField.Text))
        {
            MessageBox.Show("Please complete", "Unable to save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

        return;
        }
        saveInfo();
        Form myForm = Start.getForm();
        myForm.Show();
        this.Close();
    }
  • 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-15T13:59:23+00:00Added an answer on June 15, 2026 at 1:59 pm

    See: http://www.codeproject.com/Articles/13338/Check-If-A-String-Value-Is-Numeric

    public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle)
    {
        Double result;
        return Double.TryParse(val,NumberStyle,
            System.Globalization.CultureInfo.CurrentCulture,out result);
    }
    

    Edit:

    Usage

    private void saveAndExitBtn_Click(object sender, EventArgs e)
        {
            if (!isNumeric(custZipField.Text, System.Globalization.NumberStyles.Integer))
            {
                MessageBox.Show("Please enter a valid post code", "Unable to save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
    
            if (String.IsNullOrEmpty(custNameField.Text) || String.IsNullOrEmpty(custAddressField.Text) ||
                String.IsNullOrEmpty(custZipField.Text) || String.IsNullOrEmpty(custStateField.Text) ||
                String.IsNullOrEmpty(custAgeField.Text))
            {
                MessageBox.Show("Please complete the entire form", "Unable to save", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
    
            return;
            }
    
            //save the data
            saveNewCustomerInfo();
            //next, retrieve the hidden form's memory address
            Form myParentForm = CustomerAppStart.getParentForm();
            //now that we have the address use it to display the parentForm
            myParentForm.Show();
            //Finally close this form
            this.Close();
        }//end saveAndExitBtn_Click method
    
        public bool isNumeric(string val, System.Globalization.NumberStyles NumberStyle)
        {
            Double result;
            return Double.TryParse(val, NumberStyle,
                System.Globalization.CultureInfo.CurrentCulture, out result);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello I have a WinForm app that generates a ton of data. Currently I
I currently have a form with inputs and name attributes. I'm able to get
I currently have a winform with a listbox control that allows a user to
Currently I have a WinForm user control in the Excel CTP, which in turn
-Hello, looking for some help. We currently have a winform app used to do
I have a vb application consisting of several winForms and code files. Is it
I have created a user control on winform where i want to display some
in my Winform Application, I have Suppliers , Customers , Transport Companies . They
I have the following code that is hard coded <img src=data:image/png;base64,iVBORw0KGgoAAAANSUh .... > Through
Currently I have some buttons on my Winform that need to be disabled/enabled at

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.