价值无法比较 [英] Value cannot be compared

查看:86
本文介绍了价值无法比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码,每次运行时,我都需要它来逐一比较值,其中值来自gridview dtgTask。我可以从特定单元格中获取值,但是无法比较该值,尽管我故意输入相同的值以让它提示我想要的消息。尽管存在相同的值,但仍无法显示该消息。有帮助吗?谢谢



Hi, i have the below codes, every time it run, i need it to compare the value one by one in which the values are coming from a gridview dtgTask. I can get the value from specific cell but the value cannot be compared although i purposely enter a same value to let it prompt the message i want below. The message could not appear although there is same value. Any help? Thanks

For Each dr As DataGridItem In dtgTask.Items

    tempStartDate = dr.Cells.Item(3).Text
        If (Me.txtDateTskS.Text.Equals(tempStartDate)) Then
            Me.lblMsg.Text = "** Invalid Start Time and End Time. Same date and time has multiple tasks."
       
        End If
    Next dr

推荐答案

您没有提供足够的代码,例如<的定义code> tempStartDate ,但它显示为虽然您尝试将字符串( txtDateTskS.Text )与 DateTime 值进行比较,但这不起作用。



此外,您不必在所有内容中放置 Me。
You don't provide enough code, like the definition of tempStartDate, but it appears as though you're trying to compare a string (txtDateTskS.Text) to a DateTime value, which will not work.

Also, you don't have to put Me. in front of everything.


这篇关于价值无法比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆