کد:
'Hide a UserForm's Close Button
'Find the userform's Window
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'Get the current window style
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
'Set the new window style
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Const GWL_STYLE = -16
Const WS_SYSMENU = &H80000
Private Sub UserForm_Initialize()
Dim hWnd As Long, lStyle As Long
'Which type of userform
If Val(Application.Version) >= 9 Then
hWnd = FindWindow("ThunderDFrame", Me.Caption)
Else
hWnd = FindWindow("ThunderXFrame", Me.Caption)
End If
'Get the current window style and turn off the Close button
lStyle = GetWindowLong(hWnd, GWL_STYLE)
SetWindowLong hWnd, GWL_STYLE, (lStyle And Not WS_SYSMENU)
End Sub
اين كد باعث ميشه كه دكمه خروج از بالاي فرم حذف بشه و پنجره قابل بسته شدن نباشه كه البته ضروري هم نيست. من ترجيح دادم دكمه حذف بشه
کد:
Sub code()
Dim i As Integer, j As Integer, pctCompl As Single
For i = 1 To 100
pctCompl = i
progress pctCompl
Application.Wait Now() + TimeSerial(0, 0, 1)
Next i
Unload UserForm1
End Sub
Sub progress(pctCompl As Single)
UserForm1.Text.Caption = pctCompl & "%"
UserForm1.Bar.Width = pctCompl * 2
DoEvents
End Sub
اين كد همان فرايندي هست كه قرار هست انجام بشه و ما درصد پيشرفت اين فرايند رو متوجه بشيم.
علاقه مندی ها (Bookmarks)