Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Centering a dialog box

Posted on 2003-12-08
7
Medium Priority
?
191 Views
Last Modified: 2010-05-03
I wanted to write a general routine that centers a dialog box.  I had the following routine, but when I ran the code through a code analyzer, it reported that the prototype was incorrect.  Is it and if so, please explain what's wrong.

Thanks.

Public Sub CenterDlgBox(ByVal v_frm As Form)
       On Error Resume Next

        v_frm.Top = (Screen.Height - v_frm.Height) / 2
        v_frm.Left = (Screen.Width - v_frm.Width) / 2
end sub
0
Comment
Question by:halfondj
[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
7 Comments
 
LVL 14

Expert Comment

by:ajexpert
ID: 9896080
Hi,
  Check if you are passsing v_frm as Form object and not a string
0
 

Author Comment

by:halfondj
ID: 9896125
To: ajexpert -- Please explain your answer.

Thanks.
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 9896196
How do you call centerdlgbox and where do you call from?

Do you call like

CenterDlgBox Me
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 26

Accepted Solution

by:
EDDYKT earned 1000 total points
ID: 9896206
If you use VB6, on your form_load event

set startupposition to 2 on design time will do the trick
0
 
LVL 14

Expert Comment

by:ajexpert
ID: 9896217
Hi,
dim v_Form as Form

set v_Form as MyForm

MyForm is the form name you have declared and call it as
Call CenterDlgBox(v_Form)

0
 

Author Comment

by:halfondj
ID: 9896306
To EDDYKT:  Thanks!  That's great and simple.  Why isn't that property more popular to use?  I've seen quite a bit of documentation re: the code snippet in my question.
0
 

Author Comment

by:halfondj
ID: 9896314
BTW -- I was calling the routine like 'CenterDlgBox Me' where Me was the form (dialog box).
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

604 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