![Very Happy :D](images/smilies/icon_e_biggrin.gif)
That was very usefull, Thank you both !
I hope Bernd fixs it soon, so we can keep trying both the beta and stable releases....
P.S. I did a short func without the "," since We only use "," in this country
![Cool 8-)](images/smilies/icon_cool.gif)
Thanks and Good Luck !
P.S. I have a similar problem with FORMAT using " , " for numbers.... I want "1,000" but always get "1000"
Private function FormatNum(fNum as Double, fStr as String, lfttr as Boolean = True, rttr as boolean = True) as String
Dim thdSep as String = ","
Dim DecSep as String = "."
Dim LeftFormat as Integer
Dim RightFormat as Integer
Dim Lus as Integer
Dim CharCount as Integer = 0
Dim LusStr As String
Dim strSign as string=""
Dim dblNum as double
Dim intRemain as integer
Dim strRemain as String
Dim intPreDec as integer
Dim strPreDec as String
Dim iSignific as integer
Dim iSep as integer
dblNum = fNum
If fNum<0 then
dblNum = abs(dblNum)
strSign = "-"
End if
LeftFormat = (instr(1, fStr, ".")) - 1
RightFormat = len(fStr) - LeftFormat - 1
If Instr(1, fStr, ",") >= 1 then
DecSep = ","
thdSep = "."
LeftFormat = (instr(1, fStr, ",")) - 1
RightFormat = len(fStr) - LeftFormat - 1
End If
intPreDec = int(dblNum)
strPreDec = strSign & trim(format(intPreDec,"###############."))
if dblNum - intPreDec > 0 Then
intRemain = int((dblNum - intPreDec) * 1e10)
strRemain = right("000000000000000" & trim(format(intRemain,"###############.")),10)
else
strRemain = ""
End If
iSignific = len( val( StrReverse(strRemain) & "1" ) ) - 1
strRemain = Left( strRemain, iSignific )
? dblNum, intPredec, intRemain
iSep = int(log(dblNum) / log(10.0)) \ 3
CharCount = 0
For Lus = Len(strPreDec) to 1 step -1
CharCount = CharCount + 1
LusStr = Mid(strPreDec, Lus, 1) & LusStr
If CharCount = 3 and iSep > 0 Then
LusStr = thdSep & LusStr
CharCount = 0
iSep = iSep - 1
End If
Next
strPreDec = LusStr
if lfttr = True and LeftFormat > len(strPreDec) Then
strPreDec = Space(LeftFormat - Len(strPreDec)) & strPreDec
End If
If rttr = True Then
strRemain = Left(strRemain + Fill("0", "0", RightFormat), RightFormat)
End If
Return strPreDec & DecSep & strRemain
End Function
Private Sub Form_OnOpen()
Dim RInt as integer
dim RDoub as double
dim RSingle as single
dim RCur as currency
dim RDec as Decimal
dim RStr as String
dim RVar as Variant
RInt=22/7
RDoub=22/7
RSingle=22/7
RCur=22/7
RDec=22/7
RStr=22/7
RVar=22/7
log "Integer 22/7 = " & RInt
log "Double 22/7 = " & RDoub
log "Single 22/7 = " & RSingle
log "Currency 22/7 = " & RCur
log "Decimal 22/7 = " & RDec
log "String 22/7 = " & RStr
log "Variant 22/7 = " & RVar
End Sub
Hi cp,
This means you just wanted a comma as decimal character
and do not need the thousands separator, right ?
Slowdown wrote:...The output of RCur and RDec are in my opinion strange.
for outout do not just use "Print Pi" or "log PI" but use e.g. "log format( PI , "X.XXXXXXXXXXXXXX")"
or my XStr-function (Board "User functions")
sub main ()
dim dblPi as double
dim iC as integer
dim i as integer
dim iSignific as integer
dim iRemainder as integer
dim strRemainder as string
dim dblRemainder as double
dblPi = atn(1)*4
dblRemainder = dblPi - dblPi \ 1
'required number of decimals
iRemainder = 6
'round
if iRemainder <16 then dblRemainder = dblRemainder + 0.5 * (10.0)^(-iRemainder)
'create string
for i = 1 to iRemainder
dblremainder = dblremainder * 10
ic = iif(i<16 , dblremainder \ 1 , 0 )
dblremainder = dblremainder - ic
strRemainder = strRemainder & ic
next
'find significant decimals
iSignific = iRemainder
for i = iRemainder to 1 Step -1
if mid(strRemainder,i,1)="0" then
iSignific = iSignific - 1
else
i=1
end if
next
'output
? strRemainder
? iSignific
end sub
main()