Control re-sizing (1 Viewer)

sponsoraw

Registered User.
Local time
Today, 13:12
Joined
Jan 21, 2013
Messages
25
I've got to controls horizontally, a lebel + txt box and a label + txt box. I've been playing with it now for several hours, but with no luck. Is it possible have both txt boxes to equally re-size when you re-size the form, however I need the labels associated with the txt boxes to move along to. I've tried the anchoring, however can't get the right setup. The re-sized txt boxes overlap the labels. Any ideas?
 

BlueIshDan

☠
Local time
Today, 09:12
Joined
May 15, 2014
Messages
1,122
[LABEL][TEXTBOX][LABEL][TEXTBOX]

and you want the text boxes to scale with the width of the form's width correctly?
 

BlueIshDan

☠
Local time
Today, 09:12
Joined
May 15, 2014
Messages
1,122
Here is an idea I just quickly wrote. Not sure how it works lmao.
Code:
Private Sub Form_Resize()

    Dim spacer As Integer: spacer = 50
    
    txtOne.Width = (Form.InsideWidth / 2) - lblOne.Width - spacer
    txtTwo.Width = (Form.InsideWidth / 2) - lblTwo.Width - spacer * 5
    
    lblTwo.Left = txtOne.Left + txtOne.Width + spacer
    txtTwo.Left = lblTwo.Left + lblTwo.Width + spacer
    
    lblOne.Left = txtOne.Left - lblOne.Width - spacer
    lblTwo.Left = txtTwo.Left - lblTwo.Width - spacer
    
End Sub
 

sponsoraw

Registered User.
Local time
Today, 13:12
Joined
Jan 21, 2013
Messages
25
Hi, not sure if the word scaling is the correct term. I'm not sure if this is even possible. What I want to achieve is when you change the size of the form (make it wider than the default size) all txt boxes will also get wider to fill any blank space. This is easy to achieve with one txt box using anchoring (stretch across top), however when you have 2 txt boxes with labels next to it, it doesn't work very well, it just gets messy with txt boxes going on the top of each other and covering the labels.

Where should I stick the code you've posted? I'm not a very experience coder I'm afraid. Just learning as I go along.
 

sponsoraw

Registered User.
Local time
Today, 13:12
Joined
Jan 21, 2013
Messages
25
Hi, just tried it and I'm getting run-time error 424
Object required - see attached.
 

Attachments

  • error.JPG
    error.JPG
    32.5 KB · Views: 74

BlueIshDan

☠
Local time
Today, 09:12
Joined
May 15, 2014
Messages
1,122
You gotta replace the names in the code to match your form controls lol
 

sponsoraw

Registered User.
Local time
Today, 13:12
Joined
Jan 21, 2013
Messages
25
OK, I believe that code is for 2 labels their associated txt boxes. I'got several instances of that setup. How's that going to work?
 

Users who are viewing this thread

Top Bottom