42、VBA用户窗体列表框使用示例详解

VBA用户窗体列表框使用示例详解

1. 去除列表框中的重复项

在处理数据时,经常会遇到需要去除重复项的情况。下面的代码展示了如何使用VBA去除列表框中的重复项:

Sub RemoveDuplicates1()
    Dim AllCells As Range, Cell As Range 
    Dim NoDupes As Collection 
    Dim Item As Variant
    Set NoDupes = New Collection
    On Error Resume Next
    For Each Cell In Range("State").Cells 
        NoDupes.Add Cell.Value, CStr(Cell.Value) 
    Next Cell 
    On Error GoTo 0
    ' Add the non-duplicated items to a ListBox
    For Each Item In NoDupes 
        UserForm1.ListBox1.AddItem Item 
    Next Item 
    ' Display the count
    UserForm1.Label1.Caption = "Unique items: " & NoDupes.Count 
    ' Show the UserForm
    UserForm1.Show 
End Sub

代码逻辑如下:
- 首先,创建一个 Collection

VBA 用户窗体的认识(四) 今天继续讲用户窗体的列表框控件,因为内容实在多,所以单独一章 一、添加条目 之前提到过列表框添加项目的用法 Private Sub UserForm_Initialize() With Me.ListBox1 .AddItem "1号选择" .AddItem "2号选择" .AddItem "3号选择" .AddItem "4号选择" .AddItem "5号选择" End With End S.. 阅读详情

相关推荐

VBA 用户窗体的认识(三)

今天继续讲讲用户窗体的操作啦 一、禁用关闭按钮 先认识一下QueryClose 关闭前执行事件: Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) 这个事件是在用户窗体关闭之前发生。 第一个参数Cancel :默认是0,除了0之外的任何数都会停止QueryClose事件; 第二个参数CloseMode:有以下四个参数。这个参数的意思是关闭这个程序的方式有哪些,比如说用户点了右上角的X,或者..

叶雪青的博客 3557

VBA 用户窗体的应用

用户窗体,今日继续~每次都是一样的标题,这次换了下 一、使用外部控件做个简单的音乐/视频播放器 对着工具栏点一下右键,就会出现附加组件,找到需要用的外部组件就可以啦,比如咱们要做个视频播放,只需要在附加组件中添加 WindowsMediaPlayer即可,结合昨天我们的列表框,做个简单的音乐或者视频播放器: 具体代码如下(CommandButton1 是播放按钮,CommandButton2是打开文件夹按钮): Private Sub CommandBut...

叶雪青的博客 2661

【Excel VBA 编程】使用用户窗体UserForm制作进度条

执行耗时的操作时,为了避免界面“卡死”并提升用户体验,利用用户窗体(UserForm)来显示一个进度条,实时反馈操作进度

wei1019的专栏 1406

【VBA研究】EXCEL启动时自动启动窗体

作者:iamlaosong VBA编程时为了界面美观,我们经常用到窗体Form,那么,如何做到让VBA窗体在EXCEL启动时自动运行呢? 方法有二,第一,双击ThisWorkbook,输入以下代码(Open事件): Private Sub Workbook_Open() UserForm1.Show End Sub 第二,也可以插入一个模块,输入下面自启动代码: Sub Auto_

驽马十驾 才定不舍 1万+

34、Excel VBA用户窗体实用技巧与ListBox控件全解析

本文详细解析了Excel VBA中用户窗体与ListBox控件的实用技巧,涵盖禁用关闭按钮、动态调整窗体大小、通过滚动条实现工作表缩放与滚动、ListBox项目添加与筛选、多选处理、多列显示、数据过滤及工作表激活等功能。结合代码示例与应用建议,帮助开发者提升VBA应用程序的交互性与用户体验。

u6v7w8x的博客 152

24、VBA中集合对象的使用与列表框操作

本文详细介绍了在VBA编程中如何使用集合对象(Collection)来存储和管理用户窗体中列表框的选中项,涵盖集合的添加、删除、恢复和清空操作。结合实际示例,讲解了如何通过事件处理程序实现选中项属性展示、显示/隐藏详细信息区域以及选择关联单元格范围等功能,并提供了常见问题与解决方案,帮助开发者高效实现交互式Excel VBA应用。

convnet3designer的博客 92

Excel VBA用户窗体编程从入门到实战

Excel VBA用户窗体(UserForm)是构建交互式Excel应用程序的核心组件之一。它允许开发者创建自定义对话框,实现与用户的高效交互。通过窗体,用户可以输入数据、选择选项、触发操作,从而显著提升办公自动化的效率与用户体验。本章将从用户窗体的基本概念入手,解析其在Excel VBA开发中的作用,并结合实际场景,说明其在数据录入、查询、设置配置等自动化任务中的典型应用,为后续章节的实践打下理论基础。以下是用户窗体创建与关闭的完整生命周期流程图:graph TD。

weixin_33557333的博客 1201

STM32F429网络通信避坑指南:用CubeMX搞定LAN8720+LWIP+FreeRTOS(附完整代码)

本文详细介绍了STM32F429通过CubeMX配置LAN8720+LWIP+FreeRTOS实现网络通信的避坑指南,涵盖硬件连接、CubeMX配置、LWIP优化及调试技巧,提供完整代码和实战经验,帮助开发者高效解决以太网通信中的常见问题。

weixin_26873711的博客 145

Unity 第一人称视角控制移动、旋转

第一人称视角操作此功能主要是借鉴YouTube,写的蛮好我就搬运过来让大家也试试。

qq_36515472的博客 4202

从软体机器人到鞋垫分析:Abaqus超弹性材料(Ogden模型)仿真配置全流程

本文详细介绍了Abaqus中Ogden模型在超弹性材料仿真中的应用全流程,涵盖从实验数据导入、参数拟合到模型构建与求解优化的关键步骤。特别针对鞋垫分析等生物力学场景,提供了单元选择、接触设置和并行计算等实用技巧,帮助工程师实现高精度仿真分析。

weixin_42525385的博客 400

RK3576平台部署NanoTrack:边缘AI视觉跟踪实战指南

边缘AI部署是将深度学习模型在资源受限的嵌入式设备上高效运行的关键技术,其核心在于模型压缩、硬件适配与软件栈优化。通过INT8量化、算子融合与内存优化等原理,能显著降低模型计算量与内存占用,从而在嵌入式NPU上实现实时推理。这项技术的价值在于为安防监控、无人机视觉、工业检测等场景提供低功耗、高响应的智能感知能力。以瑞芯微RK3576平台部署轻量级视觉跟踪模型NanoTrack为例,其过程涉及模型结构分析、RKNN工具链转换、C++推理程序开发及多线程性能优化,完整展现了从算法到产品的工程化路径,为开发者提供

weixin_31887307的博客 428

嘉立创封装图下载后必做的3步优化(附批量删除机械层技巧)

本文针对从嘉立创下载的封装图,系统讲解了三步核心优化流程,以解决其直接使用时的常见问题。重点介绍了如何高效批量删除冗余的机械层,避免制造错误;并详细说明了规范丝印层间距、统一焊盘命名等关键步骤,帮助工程师将第三方封装转化为可靠、合规的设计资源,从而提升PCB设计效率与文件质量。

weixin_29227585的博客 433

C#量化交易的市场数据采集与分析:从0到1构建你的‘数据雷达’——对比5大神器,代码实战全解析!

数据是量化交易的‘氧气’,而好的数据采集与分析是你的‘呼吸机’!本文5大神器+代码实战,总有一款适合你!(本文代码均经过测试,但请根据实际需求调整!

java专栏 734

【Windows Server 2019】活动目录 (Active Directory) ——将计算机加入域和脱离域

博文介绍了如何将计算机加入AD域和脱离AD域,包括加入域,验证客户机加入到域后的信息,使用域账户用户在客户机上登录,使用本地账户用户在计算机上登录,脱离域。

VMware, Windows, Linux, Cisco, Container, Kubernetes, Kali 6169

面向 OData V4 的 Fiori elements 为何强制使用 draft、它到底是什么、以及是否能关闭

本文深入解析了SAP Fiori elements中draft handling的核心机制与必要性。关键点包括:1)draft机制通过中间版本实现复杂编辑的安全恢复与并发控制;2)Fiori elements for OData V4强制要求draft-enabled服务支持事务编辑;3)非draft服务仅适用于只读场景;4)替代方案需承担完全自定义开发的成本。文章基于SAP官方文档,系统阐述了draft在事务型应用中的基础性作用,为架构决策提供了明确指导。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 268

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

上一篇: 49、图像分割技术:区域分割与分水岭变换
下一篇: 43、Excel用户表单示例与高级技巧
python9snake
博客等级 码龄1天 0粉丝 1724原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值