Click here to Skip to main content
15,899,754 members
Home / Discussions / C#
   

C#

 
AnswerRe: Difference between Array and Loop. Pin
PIEBALDconsult23-Jan-15 3:24
mvePIEBALDconsult23-Jan-15 3:24 
GeneralRe: Difference between Array and Loop. Pin
nagendrathecoder23-Jan-15 4:05
nagendrathecoder23-Jan-15 4:05 
AnswerRe: Difference between Array and Loop. Pin
LLLLGGGG23-Jan-15 10:52
LLLLGGGG23-Jan-15 10:52 
QuestionWhy does the callback method of an EventHandler<T> need to be static? Pin
TMattC22-Jan-15 22:38
TMattC22-Jan-15 22:38 
QuestionRe: Why does the callback method of an EventHandler<T> need to be static? Pin
Richard Deeming22-Jan-15 23:34
mveRichard Deeming22-Jan-15 23:34 
AnswerRe: Why does the callback method of an EventHandler<T> need to be static? Pin
TMattC22-Jan-15 23:56
TMattC22-Jan-15 23:56 
GeneralRe: Why does the callback method of an EventHandler<T> need to be static? Pin
Eddy Vluggen23-Jan-15 0:35
professionalEddy Vluggen23-Jan-15 0:35 
QuestionDeleted Files path from HardDisk ( FAT / NTFS ) in C# Pin
Member 1139660822-Jan-15 22:35
Member 1139660822-Jan-15 22:35 
AnswerRe: Deleted Files path from HardDisk ( FAT / NTFS ) in C# Pin
OriginalGriff23-Jan-15 0:26
mveOriginalGriff23-Jan-15 0:26 
GeneralRe: Deleted Files path from HardDisk ( FAT / NTFS ) in C# Pin
deepankarbhatnagar23-Jan-15 1:17
professionaldeepankarbhatnagar23-Jan-15 1:17 
GeneralRe: Deleted Files path from HardDisk ( FAT / NTFS ) in C# Pin
Pete O'Hanlon23-Jan-15 2:59
mvePete O'Hanlon23-Jan-15 2:59 
QuestionEncrypting String Pin
EricSouthman22-Jan-15 21:59
EricSouthman22-Jan-15 21:59 
AnswerRe: Encrypting String Pin
V.22-Jan-15 22:39
professionalV.22-Jan-15 22:39 
AnswerRe: Encrypting String Pin
Eddy Vluggen23-Jan-15 0:33
professionalEddy Vluggen23-Jan-15 0:33 
AnswerRe: Encrypting String Pin
GuyThiebaut23-Jan-15 0:43
professionalGuyThiebaut23-Jan-15 0:43 
QuestionHow can I clear a file's content? Pin
kidult22-Jan-15 18:10
kidult22-Jan-15 18:10 
AnswerRe: How can I clear a file's content? Pin
Wendelius22-Jan-15 18:19
mentorWendelius22-Jan-15 18:19 
GeneralRe: How can I clear a file's content? Pin
kidult22-Jan-15 21:06
kidult22-Jan-15 21:06 
GeneralRe: How can I clear a file's content? Pin
Wendelius23-Jan-15 2:42
mentorWendelius23-Jan-15 2:42 
Questionc# validation Pin
Member 1135438622-Jan-15 13:51
Member 1135438622-Jan-15 13:51 
GeneralRe: c# validation Pin
PIEBALDconsult22-Jan-15 14:33
mvePIEBALDconsult22-Jan-15 14:33 
GeneralRe: c# validation Pin
Member 1135438622-Jan-15 17:17
Member 1135438622-Jan-15 17:17 
input products made on each day then get the day and week produced only out of the array
It needs to be an input box as per assignment I just am doing my head in validating as its a project the specs for it i tried the combo box :P i cant find anything in the source material to guide as to what my instructors want...the advice they give is that the string be at least 3 letters and that when i run it the days inputed into the box must be monday tuesday wednedsay thursday or friday and no numbers ... if there is an easier way im up to learning that too
I can paste the whole code
C#
private void btnInputBox_Click(object sender, EventArgs e)
       {

           int[,] toyArray = new int[4, 5]; ////4,5
           var totalToys = 0;//variable to hold and  accumulate the total

           string[] dayNameArray = { "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" };
           string specDay;
           int specWeek;
           string val = "";
           int specDayTotal;
           string Output = "";
           string Output1 = "Retrieve Products produced On A specific day";
           string Output2 = " Products produced On That day are:";
           string Output3 = "Sum of All Products Made = ";
           int num = 0;
           int Days=0;
           string dOW = "";
           for (int row = 0; row < toyArray.GetLength(0); row++)//enters loop to store data to array ,starts first row
           {
               for (int Col = 0; Col < toyArray.GetLength(1); Col++)//starts first column...
               {

                   val = Microsoft.VisualBasic.Interaction.InputBox("How Many Toys Made for Week:" + (row + 1) + "  " + dayNameArray[Col] + ":  ");//gets the string value of number entered
                   try
                   {
                       while (!(int.TryParse(val, out num)))//converts the string to a int to validate.. if the number IS NOT a Number eg.letter
                       {
                           MessageBox.Show("Not a valid number, try again.");//then sends this message
                           val = Microsoft.VisualBasic.Interaction.InputBox("How Many Toys Made for Week:" + (row + 1) + "  " + dayNameArray[Col] + ":  ");//re enter a number
                       }
                   }
                   catch (Exception)
                   {
                       MessageBox.Show("Value entered is not in a valid format");//exception message
                   }
                   toyArray[row, Col] = num;//else it stores this number for the array

               }//goes out to check next col of the row  once all columns done it goes to nEXT Row

           }
           //once ALL Rows checked it comes outta loop


           for (int row = 0; row < toyArray.GetLength(0); row++)//enters new loop to write data
           {

               for (int Col = 0; Col < toyArray.GetLength(1); Col++)
               {


                   Output += "          " + toyArray[row, Col] + "          ";
                   totalToys += toyArray[row, Col];

               }

               Output += "  " + "\r\n" + "";//first row checked sets a space between rows

           }

           specDay = Microsoft.VisualBasic.Interaction.InputBox("What Day Would You Like To Check:");// to find specific toys made on a specific day
           string sPattern = "^(Mon|(T(ues|hurs))|Fri)(day|\\.)?$|Wed(\\.|nesday)?$|T((ue?)|(hu?r?))\\.?$";//checks the entered data is a viable string(\\Length{3}?$)

           int result = Array.BinarySearch(dayNameArray, specDay, StringComparer.OrdinalIgnoreCase);

               if (System.Text.RegularExpressions.Regex.IsMatch(specDay, sPattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase))
               {

                   for (int dayCounter = 0; dayCounter < dayNameArray.GetLength(0); dayCounter++)//start loop number daycounter at 0 ,day counter of the length of array which will be 4(0-4) then add one to the count
                   {
                       if (dayNameArray[dayCounter] == specDay) // Compare specDay to the current index of the dayNameArray.If it finds a match
                       {
                           Days = dayCounter;//finds  the count and declares it as an int(eg. monday matches 0)
                       }
                   }

           }
           else
           {
               MessageBox.Show("Not A valid Day Of Week");
               specDay = Microsoft.VisualBasic.Interaction.InputBox("What Day Would You Like To Check:");
           }

           specWeek = Int32.Parse(Microsoft.VisualBasic.Interaction.InputBox("What week Would You Like To Check:"));
               try
               {
                   while (!(specWeek <= 4)&& !(specWeek == num))//converts the string to a int to validate.. if the number IS NOT a Number eg.letter
                   {
                       MessageBox.Show("Not a valid number, try again.");//then sends this message
                       specWeek = Int32.Parse(Microsoft.VisualBasic.Interaction.InputBox("What week Would You Like To Check:"));//re enter a number
                   }
               }
               catch (Exception)
               {
                   MessageBox.Show("Must Be 1 to 4");//exception message

               }
           int Week = specWeek-1;


           specDayTotal = toyArray[Week, Days];

           txtOutput.Text += "          " + "Monday       Tuesday       Wednesday        Thursday        Friday  " + "\r\n" + Output + "         " + Output1 + "\r\n" + "   " + specDay + "    Week " + (Week+1) + "\r\n" + Output2 + "   =  " + specDayTotal + "\r\n" + Output3 + totalToys;
           }

       }

AnswerRe: c# validation Pin
Mycroft Holmes22-Jan-15 15:51
professionalMycroft Holmes22-Jan-15 15:51 
GeneralRe: c# validation Pin
Member 1135438622-Jan-15 17:15
Member 1135438622-Jan-15 17:15 
GeneralRe: c# validation Pin
PIEBALDconsult22-Jan-15 18:42
mvePIEBALDconsult22-Jan-15 18:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.