ajoy123rocks
New Member
- Joined
- Jul 13, 2022
- Messages
- 9
- Office Version
- 2019
- Platform
- Windows
VBA Code:
Private Sub Game_Num_Val_Change()
Dim cntl As Control
Me.Game_Num_Val = UCase(Me.Game_Num_Val)
Set cntl = Me.Game_Num_Val
Call VerticalAlignCenter(cntl)
End Sub
Public Sub VerticalAlignCenter(ByRef ctl As Control)
MsgBox 1
On Error GoTo ErrorCode
Dim MinimumMargin As Integer
Dim BorderWidth As Integer
If Not ((TypeOf ctl Is TextBox) Or (TypeOf ctl Is Label)) Then Exit Sub
MinimumMargin = 1 * TwipsPerPoint
BorderWidth = (ctl.BorderWidth * TwipsPerPoint) / 2
ctl.TopMargin = ((ctl.Height - (ctl.FontSize * TwipsPerPoint)) / 2) - MinimumMargin - BorderWidth
ErrorCode:
Exit Sub
End Sub