


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!

Do you have trouble downloading or sending attachments in Outlook 365? Sometimes, Outlook doesn’t show them for some unknown reason, so you are unable to see them. In this post on php.cn Website, we collect some use tips for attachments not showing.

When V Rising players try to join a server that is close to or already full, they may encounter the “V Rising connection timed out” issue. If you are one of them, you can refer to this post from php.cn to get solutions. Now, keep on your reading.

Windows supplies real-time protection via Windows Security. But this feature may prevent you from doing something it thinks are dangerous. In this situation, you may want to temporarily turn on real-time protection. This php.cn post will show you how

Microsoft has started working on next year’s Windows updates very early. Recent rumors state that the next update in 2024 might be Windows 11 24H2 rather than Windows 12. Everything is uncertain now. php.cn will now take you to see some related infor

The error 0x80030001 often happens when you are attempting to copy files. The error code will be accompanied by a message that tells “unable to perform requested operation”. If you are struggling with this error, you can read this article on php.cn W

On February 13, 2024, Microsoft released KB5034765 (OS builds 22621.3155 and 22631.3155) for Windows 11 22H2 and Windows 11 23H2. This security update brings you many new improvements and bug fixes. You can learn how to download and install Windows 1

Device Manager is widely used when you need to fix some computer issues. You can check the problematic devices and decide to uninstall or update device drivers. Besides, you can also set Power Management settings in Device Manager. However, you may f

When Backup and Restore (Windows Backup) fails to work, you can choose to reset it to default. How to restore Windows Backup to default in Windows 11/10? php.cn will guide you to easily do this thing in 2 ways and let’s go to see them.


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

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Zend Studio 13.0.1
Powerful PHP integrated development environment

SublimeText3 Mac version
God-level code editing software (SublimeText3)

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),

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool