TextBox refusal
Man, you're like a Do-While loop <bg. "You have to save the settings somewhere and read
them back on next load. "
Drumroll, Demo:
Create a userform with Textbox1 and Commandbutton1 in a new workbook with at least 3
worksheets. Userform code:
Private Sub UserForm_Initialize()
If Sheets(3).Cells(1, 1).Value 5 Then
TextBox1.Width = Sheets(3).Cells(1, 1).Value
End If
End Sub
Private Sub CommandButton1_Click()
Dim W As Long
On Error Resume Next
W = Val(InputBox("How wide ?", "Textbox1 width", TextBox1.Width))
If W 5 Then
Sheets(3).Cells(1, 1).Value = W
TextBox1.Width = W
End If
End Sub
--
HTH. Best wishes Harald
Followup to newsgroup only please.
"Garry Jones" wrote in message ...
I have been trying to change the width of a textbox on a user form with
code, but it keeps on going back to it's original size that I set in
design.
How can I let a user alter the size of a text box with a number
I know how to get a number from the user, and check that number.
Say I get 80 from the user the width is currently 40
Then my code looks like this.. (after controls and reading of variables.
UserForm1.Controls(TextBox1.width) = 80
I have also tried
TextBox1.width = 80
But something is missing here.
Because when I close whatever code I write the text boxes go back to the
original place and size in the formula.
I have put these commands behind command buttons and in UserForm
Initialise. Still doens't work.
Any ideas/links?
Garry Jones
Sweden
|