Note that there are some explanatory texts on larger screens.

plurals
  1. POerror using ByVal VBA
    text
    copied!<p>In some computers I get errors when I use byVal modifier. I had in my code some of them but I manage to remove all of them but I need it in the following code:</p> <pre><code>Public Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Public Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, _ ByVal hdc As Long) As Long Public Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, _ ByVal nIndex As Long) As Long Const HWND_DESKTOP As Long = 0 Const LOGPIXELSX As Long = 88 Const LOGPIXELSY As Long = 90 '-------------------------------------------------- Public Function TwipsPerPixelX() As Single '-------------------------------------------------- 'Returns the width of a pixel, in twips. '-------------------------------------------------- Dim lngDC As Long lngDC = GetDC(HWND_DESKTOP) TwipsPerPixelX = 1440&amp; / GetDeviceCaps(lngDC, LOGPIXELSX) ReleaseDC HWND_DESKTOP, lngDC End Function '-------------------------------------------------- Public Function TwipsPerPixelY() As Single '-------------------------------------------------- 'Returns the height of a pixel, in twips. '-------------------------------------------------- Dim lngDC As Long lngDC = GetDC(HWND_DESKTOP) TwipsPerPixelY = 1440&amp; / GetDeviceCaps(lngDC, LOGPIXELSY) ReleaseDC HWND_DESKTOP, lngDC End Function </code></pre> <p>I am sure that the error is because of ByVal. I was using ByVal in more functions and they were not working but when I do it in another way (not using ByVal) they work and if I just delete this functions all the others works perfectly. I cannot understand the reason. </p> <p>Another weird thing is that it happens only in some computers (Win8, office 2013). But I have the same OS, office and security settings. The error that it gives is compilation error: </p> <p>"compilation error in hidden module: Module4"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload