Re: How To set ltext to numeric

new topic     » goto parent     » topic index » view thread      » older message » newer message

Tony,
are you saying that something is preventing you from putting a numeric value
in to a LText control?

I would have thought you could say something like...

  include tk_trim.e
  atom AccountBalance
  fldAcBalance = create(LText, ...
  . . .
  AccountBalance = 123.45
  . . .
  kDecimal = '.' -- Or ',' in Europe and some other places.
  function formatMoney(atom pVal)
    sequence lString
    lString = "$" & trim(sprintf("%9.2f", pVal))
    lString[find('.', lString)] = kDecimal
    return lString
  end function
  . . .
  setText(fldAcBalance, )


If you are not using atoms for money, but using integers to store cents
instead, then something like...

  include tk_trim.e
  integer AccountBalance
  fldAcBalance = create(LText, ...
  . . .
  AccountBalance = 12345
  . . .
  integer kDecimal
  kDecimal = '.' -- Or ',' in Europe and some other places.
  function formatMoney(atom pVal)
    sequence lString
    integer x

    lString = sprintf("%d", pVal)
    x = length(lString)
    if x = 1 then
       x = "00" & lString
       x = 3
    elsif x = 2 then
       x = "0" & lString
       x = 3
    end if
    return "$" & lString[1..x-2] & kDecimal & lString[x-1..x]
  end function
  . . .

  setText(fldAcBalance, formatMoney(AccountBalance))

------------
Derek.

----- Original Message -----
From: Tony Steward
To: EUforum
Sent: Saturday, July 13, 2002 11:19 AM
Subject: How To set ltext to numeric



Hi All,
I use win32lib57.9 and wish to know how to set ltext to accept ony numeric
input. The input would be in monetary form so a typical entry may be 30.36.
Using Judiths IDE I see it can be set to numeric but it wont allow the
decimal point

Thanks in advance

Tony

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu