精华内容
下载资源
问答
  • vba窗体
    2017-06-19 08:38:00

    Private Sub CommandButton1_Click()
    ' If IsDate(TextBox1.Text) = False Then
    ' MsgBox "请输入日期!"
    ' Exit Sub
    ' End If
    If 类别 = "" Or 维修部件 = "" Or 部门 = "" Or 申请人 = "" Or 资产编号 = "" Or 维修数量.Value = "" Then
    MsgBox "请完整输入,重新输入!"
    Exit Sub
    End If
    Dim i&, r&, sh As Worksheet
    On Error Resume Next
    Set sh = Sheets("维修申请单")
    If Not sh Is Nothing Then
    With sh
    r = .Range("b65536").End(xlUp).Row + 1
    .Cells(r, 1) = 维修编号.Text
    .Cells(r, 2) = 部门.Text
    .Cells(r, 3) = 申请人.Text
    .Cells(r, 4) = 类别.Text
    .Cells(r, 5) = 维修部件.Text
    .Cells(r, 8) = 资产编号.Text
    .Cells(r, 7) = 维修数量.Value
    .Cells(r, 6) = 简要描述.Text
    .Cells(r, 9) = Worksheets("参数1").Cells(2, 3)

    End With
    MsgBox "数据录入成功!", , "系统提示"
    End If
    End Sub
    Private Sub CommandButton2_Click()

    Set sh = Sheets("维修申请单")
    arr = sh.Range("A2").Resize(Range("b65536").End(xlUp).Row + 1, 8) 'Range("b65536").End(xlUp).Row A列最后一个非空单元格的行号
    For i = 1 To UBound(arr)
    If Str(arr(i, 1)) = Str(维修编号.Text) Then
    维修编号 = arr(i, 1)
    部门 = arr(i, 2)
    申请人 = arr(i, 3)
    类别 = arr(i, 4)
    维修部件 = arr(i, 5)
    资产编号 = arr(i, 8)
    维修数量 = arr(i, 7)
    简要描述 = arr(i, 6)
    End If
    : Next
    If 维修编号 = "" Then MsgBox "订单号:" & TextBox2 & " 不存在!", , "系统提示": Exit Sub
    End Sub
    Private Sub CommandButton3_Click()
    Set sh = Sheets("维修申请单")
    If Not sh Is Nothing Then
    arr = sh.Range("A2").Resize(Range("A65500").End(3).Row + 1, 8)
    For i = 1 To UBound(arr)
    If Str(arr(i, 1)) = Str(维修编号.Text) Then
    arr(i, 1) = 维修编号.Text
    arr(i, 2) = 部门.Text
    arr(i, 3) = 申请人.Text
    arr(i, 4) = 类别.Text
    arr(i, 5) = 维修部件.Text
    arr(i, 8) = 资产编号.Text
    arr(i, 7) = 维修数量.Value
    arr(i, 6) = 简要描述.Text

    sh.Range("A2").Resize(Range("A65500").End(3).Row + 1, 8) = arr
    End If: Next: End If
    MsgBox "维修编号: " & 维修编号 & " 数据已修改!", , "系统提示"
    End Sub
    Private Sub CommandButton4_Click()
    Set sh = Sheets("维修申请单")
    If Not sh Is Nothing Then
    arr = sh.Range("A2").Resize(Range("A65500").End(3).Row + 1, 8)
    For i = 1 To UBound(arr)
    If Str(arr(i, 1)) = Str(维修编号.Text) Then
    sh.Rows(i + 1).Delete
    N = arr(i, 1)
    End If: Next: End If
    If N = "" Then MsgBox "维修编号:" & 维修编号 & " 不存在!", , "系统提示": Exit Sub
    MsgBox "维修编号:" & N & " 已删除!", , "系统提示"
    End Sub

    Private Sub CommandButton5_Click()
    Dim i, num1, k
    num1 = Sheets("维修申请单").Cells(65536, 1).End(xlUp).Row
    Worksheets("维修核查单").Unprotect Password:="111111" '取消密码保护
    Worksheets("维修审核单").Unprotect Password:="111111"
    Sheets("维修核查单").Range("2:65536").Clear '从第二行开始清空工作表
    Sheets("维修审核单").Range("2:65536").Clear
    For i = 1 To num1
    For k = 1 To 9
    Sheets("维修核查单").Cells(i, k) = Sheets("维修申请单").Cells(i, k)
    Sheets("维修审核单").Cells(i, k) = Sheets("维修申请单").Cells(i, k)
    Next k
    Next i
    Worksheets("维修核查单").Protect Password:="111111" '添加密码保护
    Worksheets("维修审核单").Protect Password:="111111"
    Worksheets("维修申请单").Protect Password:="111111" '密码保护
    '收集硬件信息
    Call hardwareinfo '保存硬件信息
    Unload Me

    ThisWorkbook.Save '保存

    ThisWorkbook.Close '关闭工作簿

    End Sub


    Private Sub UserForm_Initialize()
    With Sheets("参数1") '部门combox项目
    s = ","
    For i = 2 To .Cells(65535, 1).End(xlUp).Row
    If InStr(1, s, "," & .Cells(i, 1).Text & ",") = 0 Then
    部门.AddItem .Cells(i, 1).Text
    s = s & .Cells(i, 1).Text & ","
    End If
    Next i
    End With

    With Sheets("参数2") '类别combox项目
    s = ","
    For i = 2 To .Cells(65535, 1).End(xlUp).Row
    If InStr(1, s, "," & .Cells(i, 1).Text & ",") = 0 Then
    类别.AddItem .Cells(i, 1).Text
    s = s & .Cells(i, 1).Text & ","
    End If
    Next i
    End With

    维修编号.Value = Year(Date) & Month(Date) & Day(Date) & Hour(Time) & Minute(Time) & Second(Time)
    Worksheets("维修申请单").Unprotect Password:="111111" '取消密码保护


    End Sub


    Private Sub 部门_Change()
    申请人.Clear
    pm = 部门
    d = ""
    For i = 2 To 1000
    Set c = Worksheets("参数1").Range("a" & i).Find(pm)
    If Not c Is Nothing Then
    If c.Offset(0, 1) <> d Then
    d = c.Offset(0, 1)
    申请人.AddItem d
    End If
    End If
    Next
    End Sub


    Private Sub 类别_Change()
    维修部件.Clear
    pm = 类别
    d = ""
    For i = 2 To 1000
    Set c = Worksheets("参数2").Range("a" & i).Find(pm)
    If Not c Is Nothing Then
    If c.Offset(0, 1) <> d Then
    d = c.Offset(0, 1)
    维修部件.AddItem d
    End If
    End If
    Next
    End Sub

    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) '让窗体的关闭按钮失效
    If CloseMode <> 1 Then
    Cancel = 1 '禁用窗体右上角的“×”
    End If
    End Sub

    转载于:https://www.cnblogs.com/gsl371-blog/p/7047143.html

    更多相关内容
  • VBA窗体日历插件.zip

    2021-10-26 22:17:03
    一款VBA窗体制作的日历小插件,直接导入使用即可!
  • 使用VB对VBA开发的窗体进行封装成DLL,窗体作用:根据配置的Excel基础数据表,在其他工作表中使用模糊查询赋值(当使用 序列 时,如果列表很长时,可以使用该工具)
  • VBA窗体中实现右键菜单功能, 主要是常用的复制、粘贴、剪切的实现
  • VBA窗体数字液晶时钟.xls,vba源码开放
  • VBA窗体中制作菜单

    2013-03-12 15:38:27
    office 办公实用实例 - 在excel VBA窗体中制作菜单.
  • 自动生成VBA窗体菜单

    2010-08-16 15:23:46
    自动生成VBA窗体菜单 '*************************** '* 菜单类 * '*************************** Option Explicit Private WithEvents MenuBar_MenuItem As MSForms.Label '菜单项 Private WithEvents WorkForm As...
  • 窗体 VB/VBA _API函数接口合集 '-------------------------------------------------------- '->Forms ' Module ' ClassModules '-------------------------------------------------------- Private Declare ...

    窗体

    VB/VBA _API函数接口合集

    '--------------------------------------------------------
    '->Forms
    '  Module
    '  ClassModules
    '--------------------------------------------------------
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function SetMenu Lib "user32" (ByVal hwnd As Long, ByVal hMenu As Long) As Long
    Private Declare Function CreateMenu Lib "user32" () As Long
    Private Declare Function AppendMenu Lib "user32" Alias "AppendMenuA" (ByVal hMenu As Long, ByVal wFlags As Long, ByVal wIDNewItem As Long, ByVal lpNewItem As Any) As Long
    Private Declare Function DestroyMenu Lib "user32" (ByVal hMenu As Long) As Long
    Private Declare Function CreatePopupMenu Lib "user32" () As Long
    Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    
    Private Const GWL_WNDPROC = (-4)
    Private Const MF_STRING = &H0&
    Private Const MF_POPUP = &H10&
    Private Const MF_SEPARATOR = &H800&
    
    
    Dim MenuWnd As Long, Dump As Long, PopupMenuID As Long, PopupMenuWnd As Long, MenuID As Long
    
    
    Private Sub UserForm_Initialize()
        If Val(Application.Version) < 9 Then
            hwnd = FindWindow("ThunderXFrame", Me.Caption)
        Else
            hwnd = FindWindow("ThunderDFrame", Me.Caption)
        End If
        MenuWnd = CreateMenu()
        
        PopupMenuID = CreatePopupMenu()
        Dump = AppendMenu(MenuWnd, MF_STRING + MF_POPUP, PopupMenuID, "Setting(&X)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 100, "save(&S)...")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 101, "backup(&E)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 102, "Exit(&X)")
        
        PopupMenuID = CreatePopupMenu()
        Dump = AppendMenu(MenuWnd, MF_STRING + MF_POPUP, PopupMenuID, "Review(&P)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 110, "Record(&L)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 111, "Review(&C)")
        
        PopupMenuID = CreatePopupMenu()
        Dump = AppendMenu(MenuWnd, MF_STRING + MF_POPUP, PopupMenuID, "Tools(&Z)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 112, "Tuninghelper(&T)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 113, "Kgthelper(&J)")
        
        PopupMenuID = CreatePopupMenu()
        Dump = AppendMenu(MenuWnd, MF_STRING + MF_POPUP, PopupMenuID, "Help(&B)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 114, "help(&F)")
        Dump = AppendMenu(PopupMenuID, MF_STRING, 115, "about(&Y)")
        
        Dump = SetMenu(hwnd, MenuWnd)
        PreWinProc = GetWindowLong(hwnd, GWL_WNDPROC)
        SetWindowLong hwnd, GWL_WNDPROC, AddressOf MsgProcess
    End Sub
    
    
    Private Sub UserForm_Terminate()
        DestroyMenu MenuWnd
        DestroyMenu PopupMenuID
        DestroyMenu PopupMenuWnd
        SetWindowLong hwnd, GWL_WNDPROC, PreWinProc
    End Sub
    

    模块

    '--------------------------------------------------------
    '  Forms
    '->Module
    '  ClassModules
    '--------------------------------------------------------
    Public PreWinProc As Long, hwnd As Long
    
    Public Declare Function CheckMenuRadioItem Lib "user32" (ByVal hMenu As Long, ByVal un1 As Long, ByVal un2 As Long, ByVal un3 As Long, ByVal un4 As Long) As Long
    Public Declare Function CheckMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDCheckItem As Long, ByVal wCheck As Long) As Long
    Public Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
    Public Const MF_UNCHECKED = &H0&
    Public Const MF_CHECKED = &H8&
    Public Const MF_DISABLED = &H2&
    Public Const MF_GRAYED = &H1&
    Public Const MF_ENABLED = &H0&
    
    Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function GetMenu Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function GetSubMenu Lib "user32" (ByVal hMenu As Long, ByVal nPos As Long) As Long
    Private Const MF_BYCOMMAND = &H0&
    
    
    
    Public Function MsgProcess(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
        Dim SubMenu_hWnd As Long
        Select Case wParam
            Case 100
                MsgBox "YourChoose: Save Button"
            Case 101
                MsgBox "YourChoose: Backup Buttion"
            Case 102
                Unload UserForm1
            Case 110
                MsgBox "YourChoose: Record Button"
            Case 111
                MsgBox "YourChoose: Review Button"
            Case 112
                MsgBox "YourChoose: Tuninghelper Button"
            Case 113
                MsgBox "YourChoose: Kgthelper Button"
            Case 114
                MsgBox "YourChoose: help Button"
            Case 115
                MsgBox "YourChoose: about Button"
            Case Else
                MsgProcess = CallWindowProc(PreWinProc, hwnd, Msg, wParam, lParam)
        End Select
    End Function
    
    展开全文
  • 本资源是利用Excel VBA实现有窗体的小程序实例,可以直接查看源码,内部有包含:窗体建设、隐藏/显示按钮、动态计时器(精确到毫秒)、数据闪烁对比等一系列功能,供大家参考。绝大多数代码均含有注释。
  • 该文件为 ExcleVBA 用户窗体控件的属性值含义及用法。 主要包含一些常用模块。其中列举了每种情况所对应的含义及使用方法。 本文件只对用户窗体中属性进行了一定的注释,具体语法的使用如果不太明白请咨询百度。
  • VBA窗体增加最大化、最小化窗体按钮调用方法函数代码窗体例子 VBA窗体默认只有一个关闭按钮,没有最大化和最小化按钮,下面的代码可以方便的为窗体增加最大、最小化按钮,让窗口使用更方便。 调用方法 窗体最大...

    给VBA窗体增加最大化、最小化窗体按钮


    VBA窗体默认只有一个关闭按钮,没有最大化和最小化按钮,下面的代码可以方便的为窗体增加最大、最小化按钮,让窗口使用更方便。

    调用方法

    窗体最大最小化 Me
    窗体最大化 Me
    

    函数代码

    '窗体的最大最小化
    Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    Public Const GWL_STYLE = (-16)
    Public Const WS_MAXIMIZEBOX = &H10000
    Public Const WS_MINIMIZEBOX = &H20000
    Public Const WS_THICKFRAME = &H40000
    Public Const SW_MAXIMIZE = 3
    Public Const SW_MINIMIZE = 6
    Public Const SW_NORMAL = 1
    
    '设置屏幕,0=X,1=Y
    Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    
    Public Sub 窗体最大最小化(窗体 As Object)
       Dim hWndForm As Long, MyType As String
       Dim iStyle As Long
       hWndForm = FindWindow("ThunderDFrame", 窗体.Caption) '取得窗口句柄
       iStyle = GetWindowLong(hWndForm, GWL_STYLE)          '取得窗口样式
       iStyle = iStyle Or WS_THICKFRAME                     '重新设置窗口样式
       iStyle = iStyle Or WS_MINIMIZEBOX                    '添加最小化按钮
       iStyle = iStyle Or WS_MAXIMIZEBOX                    '添加最大化按钮
       SetWindowLong hWndForm, GWL_STYLE, iStyle            '应用样式
    End Sub
    
    Public Sub 窗体最大化(窗体 As Object)
       Dim hWndForm As Long, MyType As String
       Dim iStyle As Long
       hWndForm = FindWindow("ThunderDFrame", 窗体.Caption) '取得窗口句柄
       iStyle = GetWindowLong(hWndForm, GWL_STYLE)          '取得窗口样式
       iStyle = iStyle Or WS_THICKFRAME                     '重新设置窗口样式
       'iStyle = iStyle Or WS_MINIMIZEBOX                    '添加最小化按钮
       iStyle = iStyle Or WS_MAXIMIZEBOX                    '添加最大化按钮
       SetWindowLong hWndForm, GWL_STYLE, iStyle            '应用样式
    End Sub
    

    窗体例子

    在这里插入图片描述
    ——专注办公软件的二次开发及培训,你有问题,我有思路!
    ——微博、微信、CSDN同号:w_dexu
    ——转载请注明出处!

    微信二维码扫码加微信

    展开全文
  • VBA窗体录入数据.xlsm

    2022-04-19 18:05:59
    VBA窗体录入数据.xlsm
  • vba窗体控件基础

    2014-08-06 17:10:13
    本文详细介绍了用户窗体的基本概念及常用技术
  • 本人主要介绍了VBA窗体控件的一些基本操作内容,各种常用属性,常用操作等,基本涵盖了全部常用的控件,给出了代码样例,适用于初学者,欢迎感兴趣的下载学习,不明之处请留言。
  • 如图所示,需要在窗体上显示当前系统时间: 首先,我们看一下now函数的原型: Now 函数  语法:Now  说明:返回一个 Variant (Date),根据计算机系统设置的日期和时间来指定日期和时间。  示例: Private Sub ...

    如图所示,需要在窗体上显示当前系统时间:

    在这里插入图片描述
    首先,我们看一下now函数的原型:

    Now 函数
      语法:Now
      说明:返回一个 Variant (Date),根据计算机系统设置的日期和时间来指定日期和时间。
      示例:

    Private Sub CommandButton1_Click()
        Dim a As Variant
        a = Now
        MsgBox a
    End Sub
    

    展开全文
  • 窗体控件名加参数等 Controls("Label" & (41 + I)).Caption = "中了第" & ws1.Range("g23") & "个" & Chr(10) & ws1.Range(" k23") & "*" & ws1.Range(" m23") Controls("Label" &...
  • 窗体控件属性中文解释查询大全,Excel版本 包含53个控件的属性中文对照
  • VBA窗体最大化、最小化、调整大小

    千次阅读 2018-12-15 08:48:34
    VBA窗体最大化、最小化、调整大小 Option Explicit Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long ...
  • VBA窗体画图

    千次阅读 2018-05-22 11:13:30
    由于VBA拿掉了专门画图的函数,所以需要调用系统画图API'下面代码复制到模块Declare Function FindWindow _Lib "user32" Alias "FindWindowA" _(ByVal lpClassName As String, _ByVal ...
  • excle-VBA-窗体控件属性中文解释查询大全,可帮助刚学习VBA窗体的同学
  • VBA窗体和控件初接触(2):

    千次阅读 2020-03-10 09:04:52
    ActiveX控件(activeX并不能直接用到窗体,和窗体的事件也略有不同,比如getfoucs,窗体里是enter等) 窗体 窗体控件 代码设置优先级更高,尽量少用属性栏,而是用代码设置, 很多属性,既可以在属性栏设置,...
  • 类是VBA的魂,如果理解了类的知识,那么很多VBA的理论会很容易理解。所以我们要理解类,在理解的基础上掌握它的应用。今日课题需求:在做选择题时1)对于单选这种类型,一共多个答案,如果选择了一个那么其他的将不被...
  • VBA窗体和控件初接触(1):

    千次阅读 2020-03-05 15:52:51
    1 窗体 form 1.1创建窗体 form (默认名:userform) 和插入模块一样,插入用户窗体即可 1.2 如何运行/显示 窗体? 1.2.1 显示窗体的代码方法 据说,单写一句 userform1.show 也是可以的,因为VBE会自动先 load ...
  • VBA窗体最大化最小化按钮实现

    千次阅读 2018-12-07 23:24:20
    用户窗体,如下图所示: 如果此时运行,得到的效果如下所示,是没有最大化和最小化窗口的: 下面我们就来添加最大化最小化功能的实现。 双击窗体,进入代码编辑界面,输入以下代码: Option Explicit Private ...
  • 他山之石——VBA窗体事件

    千次阅读 2018-06-29 23:47:35
    继续学习VBA!
  • 今天我们来看一下VBA窗体中的ListView控件的基本用法。ListView控件的最基本用法是在窗体中以表格形式显示数据,是应用非常广泛的一个窗体控件。控件工具箱在初始状态下是没有ListView控件的,需要我们在工具-附加...
  • VBA窗体操作

    千次阅读 2016-11-14 13:31:06
    窗体 (80) MsgBox “Hello!” '消息框中显示消息Hello (81) Ans=MsgBox(“Continue?”,vbYesNo) '在消息框中点击“是”按钮,则Ans值为vbYes;点击“否”按钮,则Ans值为vbNo。 If MsgBox(“Continue?”,vbYesNo)...
  • '****************************************'---此模块演示了给窗体添加最大最小化按钮---'****************************************Option Explicit'以下声明API函数#If Win64 Then '64位Private Declare PtrSafe ...
  • vba窗体控件大小适应

    千次阅读 2016-11-24 09:49:34
    Dim ctl As Control '窗体控件变量 Dim pos As New Collection '控件 位置比例参数 Dim lng As New Collection '控件 大小比例参数 Private Sub UserForm_Initialize() '利用集合记录各个控件与窗体比例的...
  • VBA编写的程序中,如果可以在运行时动态创建控件无疑是非常有用的,因为有些控件是无法预先得知的,这样就更必须在运行时动态创建然后设置相应控件属性。控件的名称如下: Forms.Checkbox.1(复选框) Forms....

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 5,694
精华内容 2,277
关键字:

vba窗体

友情链接: multicol_combo.rar