以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  请教:下拉窗口为选择值时会报错,代码那里有错?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=55134)

--  作者:bahamute
--  发布时间:2014/8/11 15:52:00
--  请教:下拉窗口为选择值时会报错,代码那里有错?
下拉窗口有若干复选框控件,选择之后,点击确定按钮,被选中的复选框名称生成字符串
故障现象:如果一个也未勾选,则会报错,提示“未将对象引用设置到对象的实例”


确定按钮代码:
Dim str As String
For i As Integer= 1 To 16    
    If e.Form.Controls("CheckBox" & i).checked = True Then
        str= str & "," & e.Form.Controls("CheckBox1" & i).text
    End If
Next
e.Form.DropDownBox.Value= str.trim(",")
e.Form.DropDownBox.CloseDropDown()

--  作者:有点甜
--  发布时间:2014/8/11 15:54:00
--  
Dim str As String = ""
For i As Integer= 1 To 16    
    If e.Form.Controls("CheckBox" & i).checked = True Then
        str= str & "," & e.Form.Controls("CheckBox1" & i).text
    End If
Next
e.Form.DropDownBox.Value= str.trim(",")
e.Form.DropDownBox.CloseDropDown()

--  作者:Bin
--  发布时间:2014/8/11 15:55:00
--  
Dim str As String=""
For i As Integer= 1 To 16    
    If e.Form.Controls("CheckBox" & i).checked = True Then
        str= str & "," & e.Form.Controls("CheckBox1" & i).text
    End If
Next
e.Form.DropDownBox.Value= str.trim(",")
e.Form.DropDownBox.CloseDropDown()

--  作者:lsy
--  发布时间:2014/8/11 16:05:00
--  
Dim str As String
For i As Integer= 1 To 16    
    If e.Form.Controls("CheckBox" & i).checked = True Then
        str= str & "," & e.Form.Controls("CheckBox1" & i).text
    End If
Next
If str > "" Then
   str = str.Trim(",")      
End If
e.Form.DropDownBox.Value= str
e.Form.DropDownBox.CloseDropDown()