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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Seperate decimal from whole number

Seperate decimal from whole number

Scheduled Pinned Locked Moved Visual Basic
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vertig0730
    wrote on last edited by
    #1

    I am trying to edit the decimal part of a number so if a person enters 40.25 i can chane it to 40.375 but i need it to work with any whole number any ideas? I was thinking i could use: dim a as decimal dim b as integer dim c as decimal a = textbox1.text b = textbox1.text if a - b = .25 then c = b + .375 textbox2.text = c I wished we used the metric system in the US would make my like easy 1. Out of clutter, find simplicity. 2. From discord, find harmony. 3. In the middle of difficulty lies opportunity. Albert Einstein three rules of work

    C 1 Reply Last reply
    0
    • V vertig0730

      I am trying to edit the decimal part of a number so if a person enters 40.25 i can chane it to 40.375 but i need it to work with any whole number any ideas? I was thinking i could use: dim a as decimal dim b as integer dim c as decimal a = textbox1.text b = textbox1.text if a - b = .25 then c = b + .375 textbox2.text = c I wished we used the metric system in the US would make my like easy 1. Out of clutter, find simplicity. 2. From discord, find harmony. 3. In the middle of difficulty lies opportunity. Albert Einstein three rules of work

      C Offline
      C Offline
      chrismerrill
      wrote on last edited by
      #2

      What about using "mod" to get the remainder then working with that? mod = Divides two numbers and returns only the remainder. For Example: 40 mod 1 = 0 40.25 mod 1 = .25 So you could write something like this to get the decimal(remainder) part of any number entered: dim d as single = input mod 1 if d = .25 then 'do something end if

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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