Table of Contents

RDC11042: Write # of a number between -1 and 1

Severity: Warning  ·  Family: RDC (Rubberduck Core analyzers)  ·  Raised by: NumberTextAnalyzer

Write # writes a number that can be between -1 and 1: a Single, Double, Currency or Variant value, or a literal such as 0.5.

VBA writes such a number with no zero before its decimal point: Write #1, 0.5 writes .5, and -0.25 is -.25. MS-VBAL §5.4.5.9 writes the number as let-coercion to String does, with the zero: 0.5. RD-VBA writes it as Microsoft Office VBA does, and this warning marks a file whose text depends on that difference. Input # reads either form back.

How it is raised

Situation Example Resolution
Another program reads the file. Write #1, price, with price a Currency, read by a program that expects 0.5 Write the text yourself: Print #1, Format$(price, "0.00"). Format$ uses the regional decimal separator, where Write # always writes ..
The value is never a fraction. Write #1, count, with count a Double that holds whole numbers Declare it Long, or convert it first: Write #1, CLng(count).

See also


ACCUEIL • HOME | ℹ️ BIENVENUE • WELCOME | 🧩 BÂTISSONS • BUILD | RD-VBAL | SDK | 🌐 rubberduckvba.ca