Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Zahlen abrunden

Empfohlene Antworten

Veröffentlicht

Hallo,

ich führe mit VB eine Rechnung durch, in der ich eine Zahl mit nachkommastellen bekonmmen kann. Diese Zahl soll generell ohne nachkomastelle abgerundet werden. Beispiel 22,3 soll gleich 22 sein.

Die Funktion Round und Fix haben mir da nicht wirklich weiter geholfen. Hat jemand von euch eine gute Idee ?

Gruß Patrick

Eine entsprechende Funktion habe ich nicht parat, aber mit einer Umwandlung zu Int müsste es gehen.

Versuch es mal mit der Round-Funktion.

Hallo, folgendes Problem:

Ich teile Werte(nur ganze Zahlen) durch 2. Die Werte, die auf ",0" enden sollen so bleiben, die Werte, die auf ",5 " enden sollen aufgerundet werden. Round() rundet bei 0,5 jedoch noch ab. Gibt es eine Art Modulo bei VB? So dass ich eventuell eine Bedingung einbauen könnte à la "wenn Rest = 5 dann Ergebnis plus 1" ???

hi,

folgendes

Private Function floor(ByVal dbl As Double) As Double

    Dim s As String

    s = CStr(dbl)

    If (InStr(1, s, ",") > 0) Then

        s = Left(s, InStr(1, s, ",") - 1)

    End If

    floor = CDbl(s)

End Function

sollte gehen. gebe aber keine garantie...

cast in einen integer sollte bei 22,8 auch 23 liefern, wenn mich nicht alles täuscht

hth...

Original geschrieben von Nobody

[...]@Peregrim : nein Int(22.6) ist 22.

@Nobody: hmm, habe es gerade ausprobiert, Debug.Print CInt(22.6) ergibt bei mir 23.

umgebung:

vb6.0 sp4

os: w2k

ist das mit vb.net anders?

okay, ich habs gesehen. Int() nicht CInt(). tja, wer lesen kann ist klar im vorteil...

Hallo,

einfach nach der Berechnung das hier einfügen (x = Ergebnisvariable):


x = x \ 1

WICHTIG! Backslash und nicht Slash!

Gruß

JayN

P.S. Hoffe, dass es hilft

EDIT: Ups, nee klappt doch nicht!

Original geschrieben von developer

:rolleyes:

Tut mir leid. Mein Fehler.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.