最初,我正在创建一个SQL参数:
Dim iFrame As Long
Dim OptionA As String, Risk As String, OptionB As String 'this variables are just loop-scoped, hence no need to name them loop-wise. so let's name them without any numeric index
With Me
For iFrame = 1 To 18
OptionA = Switch(.Controls("OptionButton" & iFrame & "Low"), "Low", .Controls("OptionButton" & iFrame & "Mid"), "Medium", .Controls("OptionButton" & iFrame & "High"), "High", True, "") ' the last condition (i.e.: True, "") ensures not to hit any 'Null' error should all option buttons be unchecked
Risk = .Controls("TextBox" & iFrame).Value
Select Case OptionA & Risk
Case "Medium", "High"
MsgBox ("Please enter a description of your risk mitigation")
End Select
OptionB = Switch(.Controls("OptionButton" & iFrame & "FLow"), "Low", .Controls("OptionButton" & iFrame & "FMid"), "Medium", .Controls("OptionButton" & iFrame & "FHigh"), "High", True, "")
g = iFrame ' just a guess
ActiveCell.Offset(g, 15).Value = OptionA
ActiveCell.Offset(g, 16).Value = Risk
ActiveCell.Offset(g, 17).Value = OptionB
Next
End With
VS2017然后建议我将其简化为:
Dim FileData As New SqlParameter("@FileData", SqlDbType.VarBinary, -1)
FileData.Value = DBNull.Value
所以,我申请了。然后VS2017建议我将它简化为 AGAIN :
Dim FileData As New SqlParameter("@FileData", SqlDbType.VarBinary, -1) With {
.Value = DBNull.Value
}
所以,再次,我应用它。但现在它出现了一个错误:
Dim FileData As New SqlParameter("@FileData", SqlDbType.VarBinary, -1) With {
DBNull.Value
}
首先,我是通过这些简化中获得的任何东西"简化"?原来看起来很简单。
其次,为什么VS2017会向我推荐一些导致错误的内容?
是否可以修复此错误,同时还遵循建议的简化?或者我应该只是压制有关简化的警告并坚持原来的陈述?
我知道这可能无关紧要,只是出于好奇。
感谢。
答案 0 :(得分:0)
这是Visual Studio的错误。
具体来说,“ IDE0037:使用推断的成员名称”消息。
https://github.com/dotnet/roslyn/issues/23659-“此修复程序应在15.6预览版3中发布。”