Solved

Compile Error

Posted on 2001-08-01
8
359 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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

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

Industry Leaders: 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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

733 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