c# - Message box pops up evertime -


i want messagebox show if number equal 0. part works part giving me bit of issue is, when nudtwobytwo_1_valuechanged @ 0 , increment nudtwobytwo_2_valuechanged 1 still gives me messagebox everytime increment nudtwobytwo_2_valuechanged. until increment nudtwobytwo_1_valuechanged 1. them work seperatly. if nudtwobytwo_1_valuechanged set 0 throw messagebox , same goes nudtwobytwo_2_valuechanged

i creating lottery game. min , max value set 0-20. dont want default min 1.

using system; using system.windows.forms;  namespace lotterytickets { public partial class form1 : form {     public form1()     {         initializecomponent();     }      private void nudpickfive_1_valuechanged(object sender, eventargs e)     {      }      private void nudtwobytwo_1_valuechanged(object sender, eventargs e)     {         if (cbtwobytwo.checked)              errorcheck();      }      private void nudtwobytwo_2_valuechanged(object sender, eventargs e)     {         if (cbtwobytwo.checked)         errorcheck();       }     public void errorcheck()     {                if (nudtwobytwo_1.value == 0)             {                 messagebox.show("enter number between 1 -20");             }      }        private void gbtwobytwo_enter(object sender, eventargs e)     {      }      private void cbtwobytwo_checkedchanged(object sender, eventargs e)     {      } } 

}

you need pass values error check.

public void errorcheck(int val) {          if (val == 0)         {             messagebox.show("enter number between 1 -20");         }  }  private void nudtwobytwo_1_valuechanged(object sender, eventargs e) {     if (cbtwobytwo.checked)         errorcheck((int)nudtwobytwo_1.value); }  private void nudtwobytwo_2_valuechanged(object sender, eventargs e) {     if (cbtwobytwo.checked)         errorcheck((int)nudtwobytwo_2.value);   } 

disclaimer: untested.


Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -