2011-10-21 37 views
1

如何使用Option Strict On測試DataGridViewCell.Value?如何使用Option Strict On設置DataGridViewCell.Value

If DataGridViewCell.Value = "some value" then 

給出了錯誤:

Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity. 

編輯:

的解決方案是:

If DataGridViewCell.Value.ToString = "some value" then 

回答

2

該錯誤消息不匹配您的代碼段,該錯誤不能由任務生成。被迫猜測,使用ToString()方法:

If DataGridViewCell.Value.ToString() = "some value" Then 

或者使用CStr()運算符,這是更多的VB-ish。

相關問題