当我点击编辑按钮时,我想在文本框中突出显示所有字段,这就是为什么我写了这个问题的if
语句已经解决了。但是我们可以用一行写出来吗?
If sCon.sqlReader.HasRows Then
sCon.sqlReader.Read()
txtStreetName.Text = sCon.sqlReader("StreetName")
'txtTypeDesc.Text = sCon.sqlReader("catDesc")
'If sCon.sqlReader("cityID").ToString() <> "" Then
' cboCity.SelectedValue = sCon.sqlReader("cityID")
'End If
'If sCon.sqlReader("StateID").ToString() <> "" Then
' cboState.SelectedValue = sCon.sqlReader("stateID")
'End If
'If sCon.sqlReader("countryID").ToString() <> "" Then
' cboCountry.SelectedValue = sCon.sqlReader("countryID")
'End If
End If
答案 0 :(得分:0)
请尝试以下方法之一:
选项1:
Dim foo as String = iif(bar = buz, cat, dog)
选项2:
Dim foo As Integer? = If( someTrueExpression, Nothing, 2)
选项3:
Dim foo as String = If(bar = buz, cat, dog)
希望这能帮到你!
答案 1 :(得分:0)
如果是IsDBNull(sCon.sqlReader(“cityID”))那么 cboCity.SelectedIndex = -1 其他 cboCity.SelectedValue = sCon.sqlReader(“cityID”) 结束如果
或
IIF(IsDBNull以便(sCon.sqlReader( “cityID”)), “”,sCon.sqlReader( “cityID”))