菜鸟请教:这个","咋去掉?
一个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的末尾有一个","