excel - 组合框选择发生变化,选定的值将在某个字符之后附加到文本框中
问题描述
我在组合框中有某些值,当我更改值时,我选择的值应该在某个单词之后填充到文本框中。我编写的代码不断附加组合框选定的值,而不是清除并填充新选择的值。请帮忙。
Private Sub cboTrial_Change()
Dim Searchthis As String
Dim StartTxt, MidTxt, EndTxt As String
Dim index As Integer
Dim s As String
StartTxt = VBA.vbNullString
MidTxt = VBA.vbNullString
EndTxt = VBA.vbNullString
Cells(1, 5).Value = cboTrial.Value
If Me. cboTrial.Enabled = VBA.vbTrue Then
If Me. cboTrial.Value <> VBA.vbNullString Then
Call FlagControl(cboTrial, VBA.vbFalse)
End If
Searchthis = "by"
index = InStr(1, txt, Searchthis) + 2
If index > 0 Then
StartTxt = mid(txt, 1, index)
MidTxt = Me. cboTrial.Value
EndTxt = mid(txt, index, Len(txt))
txt= StartTxt & MidTxt & EndTxt
End If
End If
End Sub
解决方案
推荐阅读
- excel - ADODB:求和函数中的缺失值
- javascript - 为什么 ji-1 值 = 2 ?如果 j = 1,我 = -1,-1
- altair - Altair:geo_shape 不适用于选择
- html - 无法执行 CSS 转换。有人可以看到并帮助我吗?
- linux - 使用 Plesk for Linux 部署 ASP.Net Core
- docker - 如何让 Docker 容器在一个 Docker 网络中相互通信
- tiff - 在带数条件下将 GeoTiff 转换为 JPEG
- php - 从表单元素循环数组
- c# - 将项目添加到 C# 中的列表时如何验证项目
- python - Django:使用来自同一模型的父级和子级创建 JSONResponse