


The type of the VB control size adaptive function does not meet the requirements!
VB control adaptive size function type does not match!
Add a module
Option Explicit
Dim FormOldWidth As Long 'The old width value of the form
Dim FormOldHeight As Long 'The old height value of the form
Public Sub ResizeInit(FormName As Form)
Dim pCtl As Control
'Set the old height and width of the form
FormOldWidth = FormName.ScaleWidth
FormOldHeight = FormName.ScaleHeight
On Error Resume Next
For Each pCtl In FormName
'Set the Tag value of the control in the form (set according to the position and size of the space)
'Returns or sets an expression that stores additional data needed by the program.
'Unlike other properties, Visual Basic does not use the value of the Tag property;
'Use this attribute to identify the object.
pCtl.Tag = pCtl.Left & " ” & pCtl.Top & " ” & pCtl.Width & " ” & pCtl.Height & " ”
Next pCtl
On Error GoTo 0
End Sub
Public Sub ResizeForm(FormName As Form)
Dim Pos(4) As Double
Dim i As Long, tmpPos As Long, staPos As Long
Dim pCtl As Control
Dim ScaleX As Double, ScaleY As Double
'Save the width and height scaling ratio of the form
ScaleX = FormName.ScaleWidth / FormOldWidth
ScaleY = FormName.ScaleHeight / FormOldHeight
On Error Resume Next
'Change the controls in the form
For Each pCtl In FormName
staPos = 1
For i = 0 To 4 'Position and size
'Get the original position and size of the control
tmpPos = InStr(staPos, pCtl.Tag, " ", vbTextCompare)
If tmpPos > 0 Then
Pos(i) = Mid(pCtl.Tag, staPos, tmpPos - staPos)
staPos = tmpPos 1
Else
Pos(i) = 0
End If
'Change the size based on the original position of the control and the form
'Proportional repositioning and resizing of controls
pCtl.Move Pos(0) * ScaleX, Pos(1) * ScaleY, Pos(2) * ScaleX, Pos(3) * ScaleY
Next i
Next pCtl
On Error GoTo 0
End Sub
Add code in Form
Private Sub Form_Load()
Call ResizeInit(Me)
End Sub
'When the size of the form changes, change the size according to the proportion of the form
'Reposition and change the size of each control in the form.
Private Sub Form_Resize()
Call ResizeForm(Me)
End Sub
Then put a few controls in the form and try changing the size of the form
VB textbox control automatically adjusts as the form changes
Control adaptive form:
Dim oldheight&, oldwidth&
Private Sub Form_Load()
oldheight = Me.Height: oldwidth = Me.Width
End Sub
Private Sub Form_Resize()
Dim cnt As Control
For Each cnt In Controls
cnt.Width = cnt.Width * Me.Width / oldwidth
cnt.Height = cnt.Height * Me.Height / oldheight
Next
oldheight = Me.Height: oldwidth = Me.Width
End Sub
The above is the detailed content of The type of the VB control size adaptive function does not meet the requirements!. For more information, please follow other related articles on the PHP Chinese website!

What’s the difference between Linux and Mac? Do you want to install Linux on Mac? This post from php.cn will show you all. You can refer to this guide to dual boot Linux and macOS.

What is MHTML? How to open or view it? What are the differences between it and HTML? How to convert MHTML to HTML? If you are looking for the answers to the above questions, you can refer to this post from php.cn.

This article focuses on the topic that deleted files keep reappearing in Windows 10, introducing the responsible reasons and feasible solutions.

This post teaches you how to deactivate Windows 10/11 by removing product key or license. You can use that product key to activate another computer later if you want. For more computer tips and tricks, you can visit php.cn Software official website.

Some Windows users report that they are prompted by the error 0164 memory size decreased screen every time they boot the computer. What’s wrong with it? If you are in the same boat, congratulations! You’ve come to the right place! In this post from p

This Page Isn’t Available Right Now is an error message you may encounter when you visit Facebook using your web browser. In this php.cn post, we will list some effective methods you can try to get rid of this error.

Windows 11 KB5010414, a new optional update for Windows 11, is available now. Do you know what’s new and fixes in it? php.cn Software will show you this information in this post. Besides, it also tells you how to download and install it on your compu

Want to pause Windows Update on your Windows 11 computer? Want to set active hours to arrange a computer restart to complete the update process? You need to know how to change Windows Update settings in Windows 11. This php.cn post will show you the


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Zend Studio 13.0.1
Powerful PHP integrated development environment

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),
