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
G

George Bradley

@George Bradley
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • How can I make my code modular?
    G George Bradley

    I need help with breaking my algorithm into modules. The reason why is because the following code at the moment is essentially duplicated three times for each calculate button on my GUI Windows Forms Application. I was wondering if I break it down in to sub-routines this can be done? Can anyone help me with this? public void park1() { string allotedTime = txtTimeLimit1.Text; string startTime = txtEntryTime1.Text; string endTime = txtExitTime1.Text; if (String.IsNullOrEmpty(allotedTime) || String.IsNullOrEmpty(startTime) || String.IsNullOrEmpty(endTime)) { MessageBox.Show("Enter all time values"); } else { TimeSpan alloted = TimeSpan.Parse(allotedTime); DateTime start = DateTime.Parse(startTime); DateTime end = DateTime.Parse(endTime); if (start > end) end = end.AddDays(1); TimeSpan duration = end.Subtract(start); //If the start time is greater than end that means the diff is above 12 hours //So subtracting the hours from a day to get the number of hours used if (TimeSpan.Compare(alloted, duration) == -1) if (TimeSpan.Compare(alloted, duration) == -1) { overTime1++; } completeTime1++; lblOverTime1.Text = "" + overTime1; int percentage = (overTime1 * 100) / completeTime1; lblOverTimePercentage1.Text = "" + percentage; if (percentage > 50) { warnWarden(); } } }

    C# question winforms algorithms help
  • Login

  • Don't have an account? Register

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