Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

make textboxes and lables resize with form 1

Status
Not open for further replies.

jh508

Technical User
Mar 26, 2001
8
0
0
US
Is there a way to make the textboxes and lables resize, with or when the screen resolution changes?
 
Change the dimension of your objects proportionaly, everytime the event Form_Resize() does occur.
example:

1.- open a new project
2.- put three label controls randomly (Label1,Label2,Label3)
3.- put three texbox controls randomly (Text1,Text2,Text3,)
4.- copy this code
5.- run it and good luck...!


let me know how you did it..!


rguia


Private Sub Form_Resize()

Dim TopMrg As Integer
Dim LeftMrg As Integer
Dim BotMrg As Integer
Dim InttMrg As Integer

Dim lh As Integer
Dim lw As Integer

TopMrg = 100
LeftMrg = 200
BotMrg = 800
IntMrg = 150

' Change the Vertical and horizontal factor
' to redifine the distribution

AriVert = Form1.Width * 0.1 '<== Vertical Factor
AriHorz = Form1.Height * 0.3 '<== Horizontal Factor

'Block #1 -----------------------------------'
' '
'Label '
Label1.Top = TopMrg '
Label1.Left = LeftMrg '
'Textbox '
Text1.Top = Label1.Top + Label1.Height '
Text1.Left = LeftMrg '
lw = AriVert - (1 * LeftMrg) '
If lw > 0 Then Text1.Width = lw '
lh = AriHorz - (1 * TopMrg) '
If lh > 0 Then Text1.Height = lh '
'END Block #1 -------------------------------'

'Block #2 -----------------------------------'
' '
'Label '
Label2.Top = TopMrg '
Label2.Left = AriVert + LeftMrg '
'Textbox '
Text2.Top = Label2.Top + Label2.Height '
Text2.Left = AriVert + LeftMrg '
lw = (Form1.Width - AriVert) - (2 * LeftMrg) '
If lw > 0 Then Text2.Width = lw '
lh = AriHorz - (1 * TopMrg) '
If lh > 0 Then Text2.Height = lh '
'END Block #2 -------------------------------'

'Block #3 -----------------------------------
' '
'Label '
Label3.Top = Text2.Top + Text2.Height '
Label3.Left = LeftMrg '
'Textbox '
Text3.Top = Label3.Top + Label3.Height '
Text3.Left = LeftMrg '
lw = Form1.Width - (2 * LeftMrg) '
If lw > 0 Then Text3.Width = lw '
lh = (Form1.Height - AriHorz) - _
(2 * TopMrg) - BotMrg '
If lh > 0 Then Text3.Height = lh '
'END Block #2 -------------------------------'

End Sub





 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top