如何使用 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
How to test for DataGridViewCell.Value with Option Strict On?
If DataGridViewCell.Value = "some value" then
Gives the error:
Option Strict On disallows operands of type Object for operator '='. Use the 'Is' operator to test for object identity.
EDIT:
The Solution is:
If DataGridViewCell.Value.ToString = "some value" then
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误消息与您的代码片段不匹配,该错误不能由作业生成。被迫猜测,使用 ToString() 方法:
或者使用 CStr() 运算符,这更像 VB 风格。
The error message doesn't match your code snippet, that error can't be generated by an assignment. Being forced to guess, use the ToString() method:
Or use the CStr() operator, that's more VB-ish.