Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default TextBox refusal

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default TextBox refusal

Not sure I grasp your problem. However, if you want
to allow the user to set the width of a TextBox and the
TextBox to have that same width the next time the
UserForm loads, it seems to me you will need to use a
worksheet cell to set the width. When the UserForm
loads, set the TextBox width per this cell with code.
Also, if the user changes the width, send the result to
the same cell.

HTH,
Merjet


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default TextBox refusal

Harald Staff wrote:

Man, you're like a Do-While loop <bg. "You have to save the settings somewhere and read
them back on next load. "


The penny - buck - krona finally dropped....

I was trying to do something that was not possible.

I have a user form. I wanted to move the physical place of the text
boxes on the user form that I see in the design layout. These values are
probably hard coded somewhere but I doubt it's possible to move them.

So I moved them by hand.

Thanks for your help and time you spent on this.

Garry Jones
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate Textbox value based on another textbox value Tdungate Excel Discussion (Misc queries) 0 February 12th 09 07:03 PM
autosum refusal to sum highlighted range lawrence Excel Worksheet Functions 4 April 30th 08 10:08 PM
Refusal to calculate Daniel Bonallack Excel Worksheet Functions 2 May 17th 06 08:39 AM
Refusal to save BizMark Excel Discussion (Misc queries) 1 October 12th 05 02:38 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 09:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"