vb.net - 如何将 SQL IN 语句与从树视图列表中选择的项目列表一起使用?
问题描述
如何将For Nextaccid
循环(如下)中的字符串值连接到一个字符串中?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim accid As String
Dim iLast As Integer
iLast = trv.Nodes.Count
Dim p As Integer = 0
For p = 0 To iLast - 1
If TrV.Nodes(p).Checked = True Then
accid = Strings.Left(TrV.Nodes(p).Text, 9)
MsgBox(accid)
End If
Next
End Sub
这给了我一个单独的字符串输出,"accid"
我想要这个输出:"accid1,accid2,accid3"
感谢支持!
解决方案
您需要在循环内构建字符串,然后在循环外执行 MsgBox。像这样的东西应该工作:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim accid As String
Dim iLast As Integer
iLast = trv.Nodes.Count
Dim p As Integer = 0
For p = 0 To iLast - 1
If TrV.Nodes(p).Checked = True Then
accid = accid & Strings.Left(TrV.Nodes(p).Text, 9) & "," 'notice the change here
End If
Next
accid = accid.Remove(accid.Length - 1, 1)
MsgBox(accid)
End Sub
推荐阅读
- minikube - 将 podman/buildah 创建的容器镜像部署到 minikube 有哪些好的工作流程?
- laravel - 如何获得我的 Eloquent 模型的属性?
- javascript - 每 2 秒将 li 的文本显示到输入中
- angular - 发生未处理的异常:集合“@angular/bazel”中未找到示意图“ng-add”
- node.js - Node, Express - 模板引擎不显示视图
- c++ - 无法创建或返回反向链接列表
- ios - 从 AppDelegate 中检索最新版本的组件失败
- python - 如何矢量化同时使用数据框的行和列元素的函数
- ios - SwiftUI在Thread中更新progressBar
- php - 更新会话销毁数据库