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 用户窗体的认识(二) 今天继续讲用户窗体啦~ 一、控件事件 昨天通过小例子,认识了按钮的点击事件(CommandButton1_Click),除此之外,还有部分控件常用事件。添加完控件后,双击一下,在上面下拉就可以查看到事件啦。 1.、UserForm的事件 ① Initialize:初始化事件 ② Activate:显示用户窗体时发生 ③Deactivate:窗体非激活的时候发生,但是隐藏了不会发生 ④QueryClose:卸载用户窗体之前发生 ⑤Terminate:卸载用户窗体之后发生 2.、S. 阅读详情

相关推荐

VBA 用户窗体的认识(三)

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

叶雪青的博客 3559

VBA 用户窗体的应用

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

叶雪青的博客 2661

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

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

wei1019的专栏 1408

【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的博客 155

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

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

weixin_33557333的博客 1208

避开STM32H7的‘保护陷阱’:从Option Byte机制深度解析读写保护原理与预防

本文深度解析STM32H723VGT6的Option Byte保护机制,详细讲解RDP读保护和WRP写保护的工作原理及配置方法,并提供硬件设计防御策略和软件预防性编程技巧,帮助开发者避免误触发保护机制导致芯片锁定的问题。

weixin_33686714的博客 449

UE5深度图与Mask图渲染实战:从基础到高级应用

本文详细解析了在UE5中渲染深度图与Mask图的完整实战流程。从启用电影渲染队列、配置自定义深度模板通道等前期准备,到构建即用型深度图材质网络与精准物体Mask生成,并深入探讨了二者结合在NPR风格化、程序化雾气及AI工作流(如ComfyUI)中的高级应用,为影视、游戏后期与AI创作提供了高效的解决方案。

weixin_29001419的博客 353

Windows10下使用Intel SGX功能(一):环境搭建

Windows 10 下测试 Intel SGX功能。

shuizhongmose的专栏 6991

基于Quartus II软件的FPGA综合实验——多功能数字钟

提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录前言一、设计要求二、设计原理三、设计过程1.数码管扫描模块2.计时模块3.闹钟模块4.闹钟响铃模块5.数码管显示模块6.整点报时功能7.模式选择模块(计时器主控电路)四、实验中遇到的困难及解决方案五、总结 前言 FPGA综合实验——多功能数字钟 基于Quartus II软件 一、设计要求 设计一个能进行时、分、秒计时的十二小时制或二十四小时制的数字钟,并具有定时与闹钟功能,能在设定的时间发出闹铃音,能非常方便地对小时、分钟和秒进.

qq_53022342的博客 2万+

别光看文档了!手把手带你用Habitat-Lab跑通第一个PointNav任务(附完整代码与避坑指南)

本文详细介绍了如何使用Habitat-Lab快速跑通第一个PointNav任务,包括环境配置、依赖安装、数据集下载与路径配置等关键步骤,并提供了完整的代码实现与常见问题排查指南。特别适合刚接触Habitat-Lab的开发者,帮助避开官方Quickstart未提及的坑,快速上手具身AI任务。

weixin_42662293的博客 283

记录Android Studio连接华为(nova)手机鸿蒙系统踩过的坑

鸿蒙系统的华为老机子比较麻烦,坑有点多,兄弟们加油!

沉迷单车的追风少年 7930

基于STM32设计的水下水质检测装置(微信小程序)(205)

本项目设计了一款基于STM32微控制器为核心的水下水质检测设备,该设备具有高度集成化、智能化的特点,能够实时监测水深、温度、浊度及溶解性总固体(TDS)等关键水质参数,并通过4G网络将数据上传至腾讯云IOT物联网平台,实现远程监控和数据分析。同时,为了便于操作和移动观测,还配套开发了微信小程序,用户可通过微信小程序实时查看并控制设备的各项功能,如调整下潜深度等。

1258

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之Port模块配置详解(MCAL配置)

RH850从0搭建Autosar开发环境【3X】- Davinci Configurator之Port模块配置详解(MCAL配置)

weixin_42412049的博客 2284

深度学习工具包 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")

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

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

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址