Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15255

[RESOLVED] Center Object or Control

$
0
0
Hi there,

I'm trying to make a combined Object and Control Center function, but I'm getting error message saying:
"object doesn't support property or method"

I'm calling my function like this at run-time:

Code:

Call CenterObject(Me, Picture1)
Code:

Public Function CenterObject(objPARENT As Object, objCTL As Control)
 
 With objPARENT
  If TypeOf objPARENT Is Form Then
  .objCTL.Left = (.ScaleWidth / 2) - (.objCTL.Width / 2)
  .objCTL.Top = (.ScaleHeight / 2) - (.objCTL.Height / 2)
  Else
  .objCTL.Left = (.Width / 2) - (.objCTL.Width / 2)
  .objCTL.Top = (.Height / 2) - (.objCTL.Height / 2)
  End If
 End With
 
End Function

Thank you for your support!

Kind regards,
Viktor

Viewing all articles
Browse latest Browse all 15255


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>