Hallo Horst,
ich habe mir zunächst nicht die Mühe gemacht, deinen Code zu
verstehen, sondern selber folgenden Test gemacht:
sub test
dim a as string
a = "a,b.c"
msgbox mid(a,2,1) & "  " & mid(a,4,1)
end sub
Die Msgbox gibt wie erwartet ", ." zurück.
Und dein Programm, das ich dann doch probiert habe, liefert bei mir
22376,93, was ich nach dem Code auch erwarten würde. Warum das
allerdings als Warnung ausgegeben wird, weiß ich nicht. Ich habe den
print-Befehl, den ich nie verwende, durch msgbox ersetzt, was ja an
der Funktionsweise von mid nichts ändert, und bekomme auch da 22376,93
als Ergebnis.
Wo ist da ein Problem?
Getestet mit 7.6.4.1 unter Windows
Grüße
Gerhard
Am 16.01.2025 um 23:51 schrieb officetechnik:
Hallo,
ich habe ein Dokument, dass unter Openoffice erstellt wurde . Das ist
schon eine Weile her.
Jetzt gibt mir das eine falsche Ausgabe.
Anscheinend gibt mid() Komma, leerzeichen u.a. als 0 zurück.
hier der vollständige code wichtig ist nur a zu verfolgen.
Horst
sub test123
print c2zahl("22.376,93 $")
end sub
'''''''''''''##########
function c2zahl(stext as string) as double
dim stext2 as string
for f =1 to len(stext)
   a=mid(stext,f,1)
    if isnumeric(a) then stext2=stext2 & a
    if a="," then stext2=stext2 & a
    'if a="." then stext2=stext2 & a
next f
on error goto fehler
i=cdbl(trim(stext2))
c2zahl=i
exit function
fehler:
on error goto 0
c2zahl=""
end function
  Privacy Policy |
  
Impressum (Legal Info) |
  
Copyright information: Unless otherwise specified, all text and images
  on this website are licensed under the
  
Creative Commons Attribution-Share Alike 3.0 License.
  This does not include the source code of LibreOffice, which is
  licensed under the Mozilla Public License (
MPLv2).
  "LibreOffice" and "The Document Foundation" are
  registered trademarks of their corresponding registered owners or are
  in actual use as trademarks in one or more countries. Their respective
  logos and icons are also subject to international copyright laws. Use
  thereof is explained in our 
trademark policy.