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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:30:37+00:00 2026-05-11T00:30:37+00:00

I am sure this is a very simple problem, but I am new to

  • 0

I am sure this is a very simple problem, but I am new to VB.NET, so I am having an issue with it.

I have a Decimal variable, and I need to split it into two separate variables, one containing the integer part, and one containing the fractional part.

For example, for x = 12.34 you would end up with a y = 12 and a z = 0.34.

Is there a nice built-in functions to do this or do I have to try and work it out manually?

  • 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. 2026-05-11T00:30:37+00:00Added an answer on May 11, 2026 at 12:30 am

    You can use Math.Truncate(decimal) and then subtract that from the original. Be aware that that will give you a negative value for both parts if the input is decimal (e.g. -1.5 => -1, -.5)

    EDIT: Here’s a version of Eduardo’s code which uses decimal throughout:

    Sub SplitDecimal(ByVal number As Decimal, ByRef wholePart As Decimal, _                  ByRef fractionalPart As Decimal)     wholePart = Math.Truncate(number)     fractionalPart = number - wholePart End Sub 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im sure this will be a simple one but have a project that started
Hey guys. This is a very simple question, I'm sure, but I'm getting myself
I'm sure this is easy but I can't figure it out: I have an
I'm sure this is a newbie question, but every time I've compiled/dl'ed a new
Very simple I'm sure, but driving me up the wall! There is a component
I have a rather strange problem. I have a very simple application that reads
Currently I have a very simple tab system set up, the problem is when
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I
Not sure this is a programming question, but we use LaTeX for all our
I'm sure this one is easy but I've tried a ton of variations and

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.