?
Solved

Compile Error

Posted on 2001-08-01
8
Medium Priority
?
362 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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 400 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

800 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