Changing width of textbox to fit the text
Is it possible to change, via code, the width of a text box to fit the entire text.
This is required because I need to display text of different lengths based on t\he selection made by the user.
Keys to the Problem Changing width of textbox to fit the text
Add a user form with two textboxes and one commandbutton.
Add the following code to commandbutton click event..
Private Sub CommandButton1_Click()
str1 = "Sample text for textbox1"
str2 = "Even Longer Sample text for textbox2 which expands to fit the text"
len1 = Len(str1)
len2 = Len(str2)
TextBox1.Width = len1 * 5
TextBox1.Value = str1
TextBox2.Width = len2 * 5
TextBox2.Value = str2
I have used 5 as char width...
you will have to find a number which will fit one char for the font used by you.
sample file uploaded to
Available for next 7 days only...
(copy full URL to download)
Note: Can someone suggest a function to reliably calcualte char width..?
This particular error can easily be resolved with a few simple steps. However, if you are not confident in your ability to use the methods below or they do not fully remove the issue on your computer, you may want to seek the assistance of a qualified repair technician who is well versed in fixing Changing width of textbox to fit the text.
- Back-up the Registry of your operating system.
- Find the Registry Key: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\OSUpgrade]
- Note: this Registry Key should already exist, if it does not exist, create it.
- Create a brand new DWORD Value that is named AllowOsUpdate
- Set the Value to 0x00000001.
- Close and reopen your Control Panel.
- Restart the Microsoft Windows.
Another Safe way to Fix the Problem: Changing width of textbox to fit the text:
How to Fix Changing width of textbox to fit the text with SmartPCFixer?
1. Click the button to download Error Fixer . Install it on your computer. Open it, and it will scan your computer. The junk files will be shown in the scan result.
2. After the scan is finished, you can see the errors and problems need to be fixed. Click Fix All.
3. The Fixing part is done, the speed of your computer will be much higher than before and the errors have been fixed.
Related: How Can You Update & Download Toshiba Satellite 5105-S501 Intel PRO 10/100 Driver v.184.108.40.206,How to Update & Download Toshiba Satellite C655D-S5139 BookPlace v.2.2.7530 driver,Method to Update & Download Toshiba Satellite L655-S5073 Realtek Wireless LAN Driver v.2.00.0011,Method to Update & Download Toshiba Satellite L840-ST2N01 Sleep Utility v.1.4.0022.000104 driver,Best Way to Update & Download Toshiba Satellite Pro S300-EZ2502 Extended Tiles for Windows Mobility Center v.1.01 driver,Best Way to Download NVidia GeForce 6100 VGA Driver v.304.51 Certified,How Can You Update & Download NVidia GeForce 9300/nForce 730i VGA Driver v.310.19 Certified,Method to Download NVidia GeForce GT 330M Driver v.340.65,How Can I Update & Download NVidia GeForce GTX 590 Driver v.280.26 WHQL,Method to Download NVidia Tesla C2050 Driver v.319.17,Way to Download RealTek RTL8100C(L) Driver v.5.01,Way to Download RealTek RTL8100E Drivers v.694,Way to Update & Download RealTek RTL8101L Auto Installation Program v.6.110 driver,Method to Update & Download RealTek RTL8111G PXE and RPL ROM code v.2.58 driver,How to Update & Download RealTek RTL8411B(N) Driver v.10.003,Best Way to Update & Download ASUS A53SV nVidia Graphics Driver v.220.127.116.1186,Method to Herunterladen ASUS K75VJ Intel Rapid Storage Technology Treiber v.18.104.22.1680,How Can You Update & Download ASUS CG8580 Intel Chipset Driver v.22.214.171.1249,Method to Update & Download ASUS K41VD Intel INF Update Driver v.126.96.36.1995,Way to Update & Download ASUS Pro70T NB Probe v.3.0.0026 driver,Can't Download PP Templates Automatically To Windows 7 W/IE 8,Can't Change Drive Letter - Vista,Can't Change Homegroup Sharing Permission,Can't Connect XP Shared Printer To Win7 Except As A Local Printer.__,Can You Connect The LAN Adapter For Wii On Your Windows 7 Laptop?
Read More: Solution to Error: check disk file NTFS,[Anwsered] Catalyst Control Center cannot be started,How to Fix - CD\/DVD Drive weird problem¿¿¿????,Solution to Error: Checkdisk screen comes up on every reboot after reinstall Windows 7,Troubleshoot:Clear Cells with Warning Message Error,Can't access c drive to open programs.,Can you use just one hard drive to store a backup disk image and restore for multiple computers?,can not install Mcafee due to Java script error,,Can Word's track changes comments print in the outside border?,cannot install old software program because computer missing indeo codec driver