vba - 尝试从用户表单中的文本框中删除文本(文本 = Label.Caption),但一次只能输入一个,因为可以输入多个
问题描述
Private Sub Option_Remove_device_Click()
If Uf_Device_selection.Option_Add_device.Value = True Then
Sheets("Sheet1").range("B2") = "Add"
Else
Sheets("Sheet1").range("B2") = "Remove"
End If
End Sub
…</p>
Private Sub Label_01_Click()
If Uf_Device_selection.Option_Add_device.Value = True Then
Text_Device_list = Label_01.Caption + " , " + Text_Device_list.Value
Else
Text_Device_list.Text = LCase(Trim(Label_01.Caption)) ''''this is the section i am stuck on '''
End If
End Sub
…</p>
Private Sub Label_02_Click()
If Uf_Device_selection.Option_Add_device.Value = True Then
Text_Device_list = Label_02.Caption + " , " + Text_Device_list.Value
Else
Text_Device_list.Text = LCase(Trim(Label_02.Caption))''''this is the section i am stuck on '''
End If
End Sub
使用修剪时,它会删除除标签之外的所有内容。我点击的标题,我只需要它以相反的方式工作。例如
文本框显示:
Label_02.Caption , Label_02.Caption , Label_02.Caption, Label_01.Caption, Label_02.Caption
现在我想通过单击 Label_02 从文本框中删除一个 Label_02.Caption
非常感谢您的任何帮助
解决方案
Private Sub La02_Click()
If Uf_Device_selection.Option_Add_device.Value = True Then
Text_Device_list = La02.Caption + " , " + Text_Device_list.Value
Else
Text_Device_list = Replace(Text_Device_list.Value, La02.Caption + " , ", "", 1, 1)
End If
结束子
所以我只需要使用一个替换函数,它为我整理了这段代码。Now when the remove option is selected then you can remove one (La.Caption) at a time.
推荐阅读
- asp.net-mvc - Adobe 嵌入的 PDF 保存到服务器提供损坏的文件
- reactjs - 在带有特征和图层的 react-mapbox-gl 中显示标记
- node.js - 一个文件中的 Json 值,基于另一个 Json 文件中的字段
- python - pyqtgraph ErrorBarItem 不绘制连接水平误差线的垂直线
- c# - 从 .NET Core 3.1 中的 AWS Lambda 函数将字节上传到 SFTP 服务器
- c# - C# 协程在 Unity 中不起作用
- java - 如何将 2 个内部类相互映射
- android - 当我运行我的颤振应用程序时,只显示空白屏幕
- c# - C# WPF 从墨水画布渲染真正的单色图像
- php - Laravel maatwebsite 导入错误和异常处理