Solved

Compile Error

Posted on 2001-08-01
8
358 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

860 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