菜鸟请教:这个","咋去掉?

guxiangdefeng 2004-03-08 02:12:31
一个form上有若干text和下拉框,任意选几个,根据所选的内容检索数据库.在下用以下代码: Dim selectString As String
selectString = "select * from studentmaster where"
If TextBox1.Text <> "" Then
selectString = selectString & " id='" & TextBox1.Text & "'"
End If
If TextBox2.Text <> "" Then
selectString = selectString & "name='" & TextBox2.Text & "',"
End If
If ComboBox1.Enabled = True And ComboBox1.SelectedItem <> "" Then
selectString = selectString & "wenhua='" & ComboBox1.SelectedItem & "',"
End If
If ComboBox2.Enabled = True And ComboBox2.SelectedItem <> "" Then
selectString = selectString & "jiankang='" & ComboBox2.SelectedItem & "',"
End If
If ComboBox3.Enabled = True And ComboBox3.SelectedItem <> "" Then
selectString = selectString & "diqu='" & ComboBox3.SelectedItem & "'"
End If
但是如果不选ComboBox3, 则selectString的末尾有一个","
...全文
50 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧