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

  • Home
  • SEARCH
  • 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 3946762
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:10:19+00:00 2026-05-20T01:10:19+00:00

Working on parsing from a text box to int to get into the incrementHour

  • 0

Working on parsing from a text box to int to get into the incrementHour method as shown.

if (txtHourPlus.Text != String.Empty)
            {
                time1.incrementHour(int.Parse(txtHour.Text));

            }

And in the time class: (the time1 objects class)

 public int incrementHour(int step)
        {
            if (step > 0 && hour < 24)
            {
                //step = step % hour;
                hour = (hour + step) % 24;
                time.AddHours(hour);
                return hour;
            }//end of if

            else
            {
                MessageBox.Show("Please enter a positive number.");

                return 0;
            }//end of else
        }//end of incrementHour

not sure why i’m getting this error. I’m converting it to the corrent data type. Because it accepts an int variable.


Alright well i got it to take the value (small mistake >.> Don’t even wanna say it)
However as someone already said the method probably needs work because i’m trying to change the Datetime value that i get in the first place and add an hour or subtract and etc etc.

  • 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-05-20T01:10:19+00:00Added an answer on May 20, 2026 at 1:10 am

    That will happen if someone has typed “foo” into the text box, for example. You should use int.TryParse instead, which lets you detect the error without an exception being thrown.

    I notice that you’re not actually using the return value of your method though – just like you’re not using the return value of time.AddHours. You are aware that DateTime.AddHours doesn’t actually modify the value you’re calling it on, aren’t you? (I suspect you’ll need to tweak that method quite a bit, actually… there are various potential problems with it, depending on exact what you’re trying to do.)

    (Finally, I’d change the method name to IncrementHour to comply with .NET conventions.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I been working on parsing out bookmarks from an export file generated by google
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
I am working on a project that requires reading text files, extracting data from
i'm working on parsing a text project where in , i have to match
I've been working on text parsing task when I found strange Postgres behavior. My
I have a function to get the values of the selected check-box from the
So my code isn't working... test.c:27: warning: passing argument 1 of ‘search’ from incompatible
Working on parsing a bunch of databases put together in an older, more freewheeling
I am working on parsing a website in my application. This is the website:
Hello Android programmers, I am working on parsing a website in my application. This

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.