Solved

Compile Error

Posted on 2001-08-01
8
357 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

821 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