Results 1 to 4 of 4

Thread: Spliting Numbers Before Minus

  1. #1

    Thread Starter
    Registered User
    Join Date
    Jan 2020

    Spliting Numbers Before Minus


    help me to get value from 5000.75 to split and display in text box should be 500 only before .

    please post if any solution for that .

    thanks in advance.

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    Re: Spliting Numbers Before Minus

    Your question is nonsensical. The title seems to suggest that you want to split on a subtraction operator but the question makes no reference to that, while the question suggests that you want to split on a dot but then uses an example that doesn't do that. It also isn't clear whether you're dealing with actual numbers, e.g. Double values, or Strings containing numerical characters. I suggest that you try again and, this time, provide a FULL and CLEAR explanation of the problem.

  3. #3
    Frenzied Member Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Skunthorpe, North Lincolnshire, England.

    Re: Spliting Numbers Before Minus

    Hi Yousaf,

    Three days on and you've not replied to jmcilhinney ?
    Maybe you've found an answer, in which case it would be polite to say so.

    As John says, your question makes no sense, maybe there's a typo where you say '5000.75' and it ought to be '500.75' or perhaps the error is in '500' and ought to read '5000'.
    To 'Split' a number as you try to describe, in it's simplest form only requires the use of an integer, i.e. a whole number without any fractions. You may want to make use of 'Math.Floor' if you don't want VB.NET to round-up the decimal part of your value.

    Along with the sunshine there has to be a little rain sometime.

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Chelmsford UK

    Re: Spliting Numbers Before Minus

    If it is '5000.75' or '500.75' and you really want the integral part...
    If it's a string dim integralPart as integer = Cint('5000.75'.Split("."c)(0))

    if it's a decimal dim integralPart as integer = CInt(Math.Floor(5000.75))

    If it really is '5000.75' and the result you want from that is 500
    dim integralPart as integer = Cint('5000.75'.Split(New String() {"0."}, StringSplitOptions.None)(0))

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width