Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Help

Help

Scheduled Pinned Locked Moved C#
help
6 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aPerfectCircle
    wrote on last edited by
    #1

    this seems easy but I just got stuck I just wanna display an error message if the textBox is left empty, and display another error Message if the entry is not an integer. I used the if statement (if var=="") MessageBox.Show(" you must enter anumber") but it gives me an error message everytime I try to compile ...Help please aPerfectTool

    RaviBeeR 1 Reply Last reply
    0
    • A aPerfectCircle

      this seems easy but I just got stuck I just wanna display an error message if the textBox is left empty, and display another error Message if the entry is not an integer. I used the if statement (if var=="") MessageBox.Show(" you must enter anumber") but it gives me an error message everytime I try to compile ...Help please aPerfectTool

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      int nFoo = 0;
      string strFoo = myTextBox.Text.Trim();
      if (strFoo.Equals (String.Empty)) {
      // empty
      ...
      } else {
      try {
      nFoo = int.Parse (strFoo);
      } catch (Exception) {
      // not an int
      ...
      }
      }

      /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      A 1 Reply Last reply
      0
      • RaviBeeR RaviBee

        int nFoo = 0;
        string strFoo = myTextBox.Text.Trim();
        if (strFoo.Equals (String.Empty)) {
        // empty
        ...
        } else {
        try {
        nFoo = int.Parse (strFoo);
        } catch (Exception) {
        // not an int
        ...
        }
        }

        /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

        A Offline
        A Offline
        aPerfectCircle
        wrote on last edited by
        #3

        hey ravi thanks for your quick response, I'm still having the same problem, when i run the code, it always do the try and catch first with leaves me with only one error message if I leave the textBox empty the program just bomb on me !!!!??? aPerfectTool

        RaviBeeR 1 Reply Last reply
        0
        • A aPerfectCircle

          hey ravi thanks for your quick response, I'm still having the same problem, when i run the code, it always do the try and catch first with leaves me with only one error message if I leave the textBox empty the program just bomb on me !!!!??? aPerfectTool

          RaviBeeR Offline
          RaviBeeR Offline
          RaviBee
          wrote on last edited by
          #4

          aPerfectCircle wrote:

          the program just bomb on me

          I'm not sure I understand. Please post your button's click handler code. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

          A 1 Reply Last reply
          0
          • RaviBeeR RaviBee

            aPerfectCircle wrote:

            the program just bomb on me

            I'm not sure I understand. Please post your button's click handler code. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

            A Offline
            A Offline
            aPerfectCircle
            wrote on last edited by
            #5

            hey Ravi I just got it working thanks for your help :) aPerfectTool

            RaviBeeR 1 Reply Last reply
            0
            • A aPerfectCircle

              hey Ravi I just got it working thanks for your help :) aPerfectTool

              RaviBeeR Offline
              RaviBeeR Offline
              RaviBee
              wrote on last edited by
              #6

              Excellent! /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups