La intención de esta pagina es publicar algunas funciones y rutinas que para mí fueron útiles, complicadas o con poca documentación.
Funciones usadas.Used functions
OpenPrinter
StartDocPrinter
StartPagePrinter
WritePrinter
EndDocPrinter
EndPagePrinter
ClosePrinter
CharToOemBuff
GetJob
agCopyData
agGetStringFromPointer
Funciones usadas.Used functions
keybd_event
mouse_event
OemKeyScan
CharToOem
VkKeyScan Lib
Funciones usadas. Used functions
CreateEllipticRgn
Errores de Redondeo en Visual Basic. Rounding errors on Visual Basic.
El problema se encuentra por ejemplo al restar 370.78 - 370 devuelve ccomo resultado el numero 0.779999999999973 cuando el resultado deberia ser 0.78 . Esta es una funcion que soluciona este problema (El primer parametro es el numero a redondear y el segundo es la cantidad de decimales. Used functions
Function Rounded(X#, Y%) As Double Rounded = Int(X# * 10 ^ Y% + 0.5) / 10 ^ Y% End Function
Este es un articulo de Microsoft con algunos problemas similares
PSS ID Number: Q111781 Article last modified on 08-29-1997 1.0 1.1 2.0 7.0 97 WINDOWS
====================================================================== The information in this article applies to: - Microsoft Access versions 1.0, 1.1, 2.0, 7.0, 97SYMPTOMS ========
Novice: Requires knowledge of the user interface on single- user computers. When you calculate using floating-point numbers, the result is not always what you expect. For example, if you use the CInt() (convert to integer) function in the calculation CInt(3.555 * 100) you receive 356 as the result, as you expect. However, the calculation CInt(4.555 * 100) results in 455 instead of 456. CAUSE ===== Errors similar to the example above occur in any programming language that uses floating-point numbers. This is because decimal fractions do not always have exact binary equivalents, which can result in rounding errors. RESOLUTION ========== There are several methods you can use to avoid rounding errors when you are using floating-point numbers: - If you are using Single numbers, convert them to Doubles and use formatting to hide the extra digits. If there are any rounding errors, they will occur at the end of the numbers where they will not affect the visible data. - Use the Currency data type. If you use currency values of four decimal places or less, rounding errors will not occur because these values are actually scaled integers rather than floating-point numbers. In code, use the at sign (@) character to use a Currency data type. For example, the calculation CInt(4.555@ * 100) results in a value of 456. - Break the calculation into two or more steps. When you list a calculation in one long line, Visual Basic (in version 7.0) or Access Basic (in earlier versions) stores the intermediate values internally. For example, in the calculation CInt(4.555 * 100) the value 455.5 is temporarily stored and used in the CInt() function. If you break the calculation into the two steps x = 4.555 * 100 CInt(x) you avoid this internal storage and thus avoid the floating-point rounding error. Additional query words: roundoff ====================================================================== Keywords : kbprg PgmOthr Version : 1.0 1.1 2.0 7.0 97 Platform : WINDOWS Hardware : x86 Issue type : kbprb Solution Type : kbworkaround ============================================================================= Copyright Microsoft Corporation 1997.