Can someone explain how to adjust my application so that regardless of what screen resolution a user is using my application will fit correctly.
Printable View
Can someone explain how to adjust my application so that regardless of what screen resolution a user is using my application will fit correctly.
It depends on your needs when you say you want your application to fit. If you just want the window to fit the entire screen you can use
Me.WindowState = vbMaximized
If you're talking about resizing controls on a form you would need to create a module with a resize sub or function. Something like this:
hope this helps a bitCode:Function resize(formname As Form)
Dim resizeamt As Single
dim swidth as single
'get the screen resolution
swidth = Screen.Width \ screen.TwipsPerPixelX
'I just guessed at these values...you'd have to test them
Select Case swidth
Case 800
resizeamt = 1
myfontsize = 9
Case 960
resizeamt = 1.3
myfontsize = 12
Case 1024
resizeamt = 1.3
myfontsize = 12
Case 1152
resizeamt = 1.4
myfontsize = 13
Case 1280
resizeamt = 1.4
myfontsize = 13
Case 1600
resizeamt = 1.6
myfontsize = 14
Case Else
'assume 800x600 for any other resolutions
resizeamt = 1
myfontsize = 9
End Select
'check each control on the form
For i = 0 To formname.Count - 1
If TypeOf formname.controls(i) Is TextBox Then
formname.controls(i).Height = formname.controls(i).Height * resizeamt
formname.controls(i).width = formname.controls(i).Width * resizeamt 'optional to change width
ElseIf TypeOf formname.controls(i) Is ComboBox Then
'you can't use .height with comboboxes, but fontsize will work
formname.controls(i).FontSize = myfontsize
ElseIf TypeOf formname.controls(i) Is ListBox Then
formname.controls(i).Width = formname.controls(i).Width * resizeamt 'optional to change width
formname.controls(i).Height = formname.controls(i).height * resizeamt
End If
Next
End Function
~Acoustic
Hi FMCAR10
Try this artical in vbworld
http://www.vb-world.net/tips/tip489.html
There is one problem with the code thought, it doesnt work well with tabstrip
Does anyone here has a solution for that?