Solved

Compile Error

Posted on 2001-08-01
8
351 Views
Last Modified: 2012-05-04
The function below returns "Compile error: Method or data member not found."  The selected code is ".X2".  

I have defined the global variable and types as follows:

Global SCREEN_SIZE As String                

Type RECT
    X1 As Integer
    Y1 As Integer
    X2 As Integer
    Y2 As Integer
End Type


Function GetScreenResolution()

Dim R As Rectangle
Dim hwnd As Integer
Dim retval As Integer

    hwnd = GetDesktopWindow()
    retval = GetWindowRect(hwnd, R)
    SCREEN_SIZE = (R.X2 - R.X1) & "x" & (R.Y2 - R.Y1)
   
End Function



What do I need to check in my references to make this work?

0
Comment
Question by:tfygold
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 14

Expert Comment

by:mgrattan
ID: 6342209
Try changing "Dim R as Rectangle" to "Dim R as RECT"
0
 
LVL 3

Expert Comment

by:casassus
ID: 6343707
Hwnd and Retval are long data type
0
 

Author Comment

by:tfygold
ID: 6344998
mgrattan,

I changed Rectangle to RECT, and then got this error - Compile error: ByRef argument type mismatch.
The "R" is highlighted in "retval = GetWindowRect(hwnd, R)".  
0
 
LVL 9

Expert Comment

by:perove
ID: 6345207
I seem to recall that the X'es in RECT should be Long.
So try to:


Type RECT
   x1 As Long
   y1 As Long
   x2 As Long
   y2 As Long
End Type


Also:

   Dim R As RECT
   Dim hWnd As Long
   Dim RetVal As Long

perove
(this is NOT tested)



0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 14

Expert Comment

by:mgrattan
ID: 6345248
In 16-bit VB/VBA it was Integer, in 32-bit versions it needs to be Long.
0
 

Author Comment

by:tfygold
ID: 6345293
perove,

I changed integer to long - still getting same error I last posted.
0
 
LVL 3

Accepted Solution

by:
casassus earned 100 total points
ID: 6345302
Try this, i test it and it work

Global SCREEN_SIZE As String

Declare Function GetDesktopWindow Lib "user32" () As Long
Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type



Function GetScreenResolution()

Dim R As RECT
Dim hwnd As Long
Dim retval As Long

   hwnd = GetDesktopWindow()
   retval = GetWindowRect(hwnd, R)
   SCREEN_SIZE = (R.Right - R.Left) & "x" & (R.Bottom - R.Top)
   
End Function
0
 

Author Comment

by:tfygold
ID: 6345974
Thanks, everybody, for your help!
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now