精华内容
下载资源
问答
  • VBA窗体资料VBA窗体资料VBA窗体资料
  • vba窗体

    2017-06-19 08:38:00
    Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) '让窗体的关闭按钮失效 If CloseMode <> 1 Then Cancel = 1 '禁用窗体右上角的“×” End If End Sub 转载于:...

    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窗体数字液晶时钟.xls,vba源码开放
  • 他山之石——VBA窗体事件.pdf
  • 他山之石——VBA窗体的使用.pdf
  • 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窗体中制作菜单

    2013-03-12 15:38:27
    office 办公实用实例 - 在excel VBA窗体中制作菜单.
  • VBA窗体中实现右键菜单功能, 主要是常用的复制、粘贴、剪切的实现
  • 请各位大神们帮帮忙我是...我想通过vba窗体做一个三级下拉菜单!三级下拉菜单前两级放在复合框内最后一级放在列表框内!所选内容放在文字框内!例如:某某省某某市某某县!然后把所选内容放在文字框内!谢谢各位大神了!
  • 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窗体最大化、最小化、调整大小

    Option Explicit 
            Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long 
            Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As
        String) 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 Const GWL_STYLE = (-16) 
            Private Const WS_THICKFRAME As Long = &H40000 ’(恢复大小) 
            Private Const WS_MINIMIZEBOX As Long = &H20000 ’(最小化) 
            Private Const WS_MAXIMIZEBOX As Long = &H10000 ’(最大化) 
    

    窗体

      Private Sub UserForm_Initialize() 
              Dim hWndForm As Long 
              Dim IStyle As Long 
              hWndForm = FindWindow("ThunderDFrame", Me.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
    
    展开全文
  • VBA窗体学习………………………………………………
  • VBA窗体画图

    千次阅读 2018-05-22 11:13:30
    由于VBA拿掉了专门画图的函数,所以需要调用系统画图API'下面代码复制到模块Declare Function FindWindow _Lib "user32" Alias "FindWindowA" _(ByVal lpClassName As String, _ByVal ...

    由于VBA拿掉了专门画图的函数,所以需要调用系统画图API

    '下面代码复制到模块

    
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    
    Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
    
    
    Declare Function Arc Lib "gdi32" (ByVal hdc As Long, _
    ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, _
    ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
    
    
    Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, _
    ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
    
    
    Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, _
    ByVal x As Long, ByVal y As Long) As Long
    
    
    Declare Function CancelDC Lib "gdi32" (ByVal hdc As Long) As Long
    
    
    Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, _
    ByVal nWidth As Long, ByVal crColor As Long) As Long
    
    
    Const PS_DASH = 1
    
    Const PS_DASHDOT = 3
    
    Const PS_DASHDOTDOT = 4
    
    Const PS_DOT = 2
    
    Const PS_NULL = 5
    
    Const PS_SOLID = 0
    
    
    Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
    
    
    Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
    
    Type POINTAPI
    
            x As Long
            
            y As Long
            
    End Type
    
    'Arc参数 类型及说明
    
    '  hdc     Long,一个显示场景的句柄
    
    '  X1,Y1   Long,指定围绕椭圆的一个矩形的左上角位置
    
    '  X2,Y2   Long,指定围绕椭圆的一个矩形的右下角位置
    
    '  X3,Y3   Long,指定圆弧起点
    
    '  X4,Y4   Long,指定圆弧终点

    '下面代码复制到窗体

    Private Sub Form_Load()
    
        Dim pt As POINTAPI
    
        Dim hPen As Long
    
        Dim hPenPrev As Long
    
    
    
        hPen = CreatePen(PS_DOT, 1, vbRed)
    
        Me.AutoRedraw = True
    
        hPenPrev = SelectObject(Me.hdc, hPen)
    
        MoveToEx Me.hdc, 10, 100, pt
    
        LineTo Me.hdc, 200, 100
    
        SelectObject Me.hdc, hPenPrev
    
        DeleteObject hPen
    
    End Sub
    
    Private Sub CommandButton1_Click()
    
        Dim hwnd As Long
    
        Dim hdc As Long
    
        Dim pt As POINTAPI
    
        Dim p0(0 To 1) '圆0圆心坐标
    
        Dim p1(0 To 1) '圆1圆心坐标
    
        Dim p3(0 To 1) '切线切点0坐标
    
        Dim p4(0 To 1) '切线切点1坐标
    
        Dim p5(0 To 7) '圆0坐标
    
        Dim p6(0 To 7) '圆1坐标
    
        Dim d0 '圆0直径
    
        Dim d1 '圆1直径
    
        Dim s0 As Double '圆心距离
    
        Dim dx, dy, dr
    
        Dim sin1 As Double '切点半径斜角正弦值
    
        Dim cos1 As Double '切点半径斜角余弦值
    
    
    
        p0(0) = 100: p0(1) = 200
    
        p1(0) = 200: p1(1) = 200
    
        d0 = 50
    
        d1 = 80
    
    
    
        dx = p1(0) - p0(0)
    
        dy = p1(1) - p0(1)
    
        dr = (d1 - d0) / 2
    
        s0 = Sqr(dx ^ 2 + dy ^ 2)
    
        cos1 = dx * dr / s0 ^ 2 - dy * Sqr(1 - (dr / s0) ^ 2) / s0
    
        sin1 = Sqr(1 - (cos1) ^ 2)
    
    
    
        p3(0) = p0(0) - d0 / 2 * cos1
    
        p3(1) = p0(1) - d0 / 2 * sin1
    
    
    
        p4(0) = p1(0) - d1 / 2 * cos1
    
        p4(1) = p1(1) - d1 / 2 * sin1
    
    
    
        p5(0) = p0(0) - d0 / 2
    
        p5(1) = p0(1) - d0 / 2
    
        p5(2) = p0(0) + d0 / 2
    
        p5(3) = p0(1) + d0 / 2
    
        p5(4) = p0(0) - d0 / 2
    
        p5(5) = p0(1) - d0 / 2
    
        p5(6) = p0(0) - d0 / 2
    
        p5(7) = p0(1) - d0 / 2
    
    
    
        p6(0) = p1(0) - d1 / 2
    
        p6(1) = p1(1) - d1 / 2
    
        p6(2) = p1(0) + d1 / 2
    
        p6(3) = p1(1) + d1 / 2
    
        p6(4) = p1(0) - d1 / 2
    
        p6(5) = p1(1) - d1 / 2
    
        p6(6) = p1(0) - d1 / 2
    
        p6(7) = p1(1) - d1 / 2
    
    
    
        hwnd = FindWindow(vbNullString, "UserForm1") '获得窗口句柄
    
        If hwnd = 0 Then
    
        Else
    
            hdc = GetDC(hwnd)
    
            Arc hdc, p5(0), p5(1), p5(2), p5(3), p5(4), p5(5), p5(6), p5(7)
    
            Arc hdc, p6(0), p6(1), p6(2), p6(3), p6(4), p6(5), p6(6), p6(7)
    
            MoveToEx hdc, p3(0), p3(1), pt
    
            LineTo hdc, p4(0), p4(1)
    
            CancelDC hdc
    
        End If
    
    End Sub
    
    展开全文
  • 自动生成VBA窗体菜单

    2010-08-16 15:23:46
    自动生成VBA窗体菜单 '*************************** '* 菜单类 * '*************************** Option Explicit Private WithEvents MenuBar_MenuItem As MSForms.Label '菜单项 Private WithEvents WorkForm As...
  • vba窗体控件基础

    2014-08-06 17:10:13
    本文详细介绍了用户窗体的基本概念及常用技术
  • Vba窗体控件imagelist

    2021-05-20 15:49:33
    <p>Imagelist控件自定义图标显示类未注册,求大神指导怎么解决,万分感谢</p>
  • vba窗体中的文本框如何在运行时显示想要显示的内容?就是显示提示信息。
  • 使用VB对VBA开发的窗体进行封装成DLL,窗体作用:根据配置的Excel基础数据表,在其他工作表中使用模糊查询赋值(当使用 序列 时,如果列表很长时,可以使用该工具)
  • VBA窗体操作

    千次阅读 2016-11-14 13:31:06
    窗体 (80) MsgBox “Hello!” '消息框中显示消息Hello (81) Ans=MsgBox(“Continue?”,vbYesNo) '在消息框中点击“是”按钮,则Ans值为vbYes;点击“否”按钮,则Ans值为vbNo。 If MsgBox(“Continue?”,vbYesNo)...
  • 有那位仁兄能提供点资料吗?关于 excell vba 窗体程序
  • 窗体动态菜单,个人感到挺好用,对于初学者有帮助啊。
  • VBA窗体函数

    千次阅读 2012-05-25 13:25:39
    使用VBA创建应用程序 来源:中数休闲 发表时间:2007-2-7 浏览次数:534 【字体:大 中 小】
  • VBA窗体转VB方法

    千次阅读 2016-04-09 18:58:42
    [求助] 求教VBE窗体导入VB的方法和导入后的使用方法  [复制链接]     ctincob 2 主题 8 帖子 0 鲜花 EH新人 积分 11 技术 0 发消息
  • 他山之石——VBA窗体事件

    千次阅读 2018-06-29 23:47:35
    继续学习VBA!
  • 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() '利用集合记录各个控件与窗体比例的...
  • 如图所示,需要在窗体上显示当前系统时间: 首先,我们看一下now函数的原型: Now 函数  语法:Now  说明:返回一个 Variant (Date),根据计算机系统设置的日期和时间来指定日期和时间。  示例: Private Sub ...
  • 他山之石——VBA窗体的使用

    千次阅读 2018-06-28 23:38:02
    继续学习VBA
  • 类是VBA的魂,如果理解了类的知识,那么很多VBA的理论会很容易理解。所以我们要理解类,在理解的基础上掌握它的应用。今日课题需求:在做选择题时1)对于单选这种类型,一共多个答案,如果选择了一个那么其他的将不被...
  • <p><img alt="" height="282" src="https://img-ask.csdnimg.cn/upload/1619503806649.png" width="596" /></p> <p><img alt="" height="108" src=...

空空如也

空空如也

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

vba窗体