We help IT Professionals succeed at work.
Get Started

Screen Resolution Problem on Userforms

733 Views
Last Modified: 2013-12-26
I have a huge form. The dimensions are:
Height: 787.5
Width: 1000

I produced on a 1680x1050 computer. When I tried it on other computers, the form didnt look as nice .
So I found the code below.

So I use scrollbars and zoom to overcome this problem.

1. My first question is how can I make this screen resolution code more flexible so it works on any type of screen resolution and looks nic.
2. Is there an easier and more efficient way to overcome the resolution problem.
With Application
.WindowState = xlMaximized
If x > 0 And y > 0 Then
'1680-1050
    If x = 1680 And y = 1050 Then
Me.Zoom = Int(.Height / Me.Height * 120)
Me.Width = .Width * 1#
Me.Height = .Height
'MsgBox x & " " & y

Me.ScrollBars = fmScrollBarsBoth
        Me.ScrollHeight = Me.InsideHeight * 1.3
        Me.ScrollWidth = Me.InsideWidth * 1.3
End If

'1280 - 1024
 If x = 1280 And y = 1024 Then
Zoom = Int(.Height / Me.Height * 140)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 2
Me.ScrollWidth = Me.InsideWidth * 2
End If

 If x = 1280 And y = 960 Then
Zoom = Int(.Height / Me.Height * 160)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 2
Me.ScrollWidth = Me.InsideWidth * 2

End If

 If x = 1280 And y = 768 Then
Zoom = Int(.Height / Me.Height * 140)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 2
Me.ScrollWidth = Me.InsideWidth * 2

End If
 If x = 1152 And y = 864 Then
Zoom = Int(.Height / Me.Height * 160)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 1.6
Me.ScrollWidth = Me.InsideWidth * 1.6

End If
 If x = 1024 And y = 768 Then
Zoom = Int(.Height / Me.Height * 180)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 1.8
Me.ScrollWidth = Me.InsideWidth * 1.8

End If
 If x = 800 And y = 600 Then
Zoom = Int(.Height / Me.Height * 200)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 2
Me.ScrollWidth = Me.InsideWidth * 2

End If

Else
Zoom = Int(.Height / Me.Height * 200)
Me.Width = .Width * 1#
Me.Height = .Height
Me.ScrollBars = fmScrollBarsBoth
Me.ScrollHeight = Me.InsideHeight * 2
Me.ScrollWidth = Me.InsideWidth * 2

End If
End With

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 2 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE