以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]求助关于DrawCell 既有数值又有文本如何判断  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=104794)

--  作者:zhengboxin
--  发布时间:2017/8/5 9:22:00
--  [求助]求助关于DrawCell 既有数值又有文本如何判断
我的代码如下,If e.Col.Name= "剩余天数" Then
    If e.Row.IsNull(e.Col.Name) = False 
        If e.Row(e.Col.Name)<8 Then  
            e.Style = "跟催"  
        ElseIf e.Row(e.Col.Name) = "超时" Then  
            e.Style = "超时" 
        ElseIf e.Row(e.Col.Name) > 7  Then  
            e.Style = "正常"  
        End If
    End If
End If

当剩余天数列有内容为超时时就提示如下:
错误所在事件:表,表A,DrawCell
详细错误信息:
调用的目标发生了异常。
从字符串“超时”到类型“Double”的转换无效。
输入字符串的格式不正确。

我的需求是当剩余天数是超时,则红色,剩余天数为7天内则显示黄色,7天外则绿色,麻烦各位老师给个思路,谢谢。

[此贴子已经被作者于2017/8/5 9:29:52编辑过]

--  作者:有点蓝
--  发布时间:2017/8/5 9:32:00
--  
If e.Col.Name= "剩余天数" Then
    If e.Row.IsNull(e.Col.Name) = False \'且该列已经输入内容
        Dim day As Integer = 0
        If Integer.TryParse(e.Row(e.Col.Name),day) Then
            If day < 7 Then \'如果该列的值小于60
                e.Style = "跟催" \'那么用"不及格"样式绘制单元格
            Else
                e.Style = "正常" \'那么用"优秀"样式绘制单元格
            End If
        Elsee.Row(e.Col.Name) = "超时" Then \'如果单元格的值大于95
            e.Style = "超时" \'那么用"优秀"样式绘制单元
        End If
    End If
End If

--  作者:zhengboxin
--  发布时间:2017/8/5 10:16:00
--  
谢谢老师,我if else 嵌套一个if else 也解决了
if 值是否超时 then

esle

   if 值<7 then

   elseif 值。。。。 then

   end if

end if