现在我用VB编写的ASP。NET中判断是否空值用什么函数,我用下面语句块提示错误:
Public Function showreply(ByVal a As String)
        Dim aa As String
        If isnull(a) then
            aa = "未回复"
        Else
            aa = "已回复"
        End If
        Return aa
    End Function
请问应如何更正,在线等待

解决方案 »

  1.   

    ==string.empty,=="",is nothing,isempty,len(str)==0
      

  2.   

    我用了==string.empty,=="",isempty,len(str)==0
    a=string.empty
    a==""
    a isempty
    len(a)==0
    都不行,因为我这里的参数a有可能是空值,因此会出现错误
    现在用
    if a is nothing then
    ……
    end if
    却判断不出来,有时候数据库明明是空值它返回还是false,请问还有哪里错了
      

  3.   

    Public Function showreply(ByVal a As String) as string
            Dim aa As String
            If a <> "" then
                aa = "未回复"
            Else
                aa = "已回复"
            End If
            Return aa
        End Function
      

  4.   

    提示错误:运算符对 类型“DBNull” 和 字符串“” 无效。
    因为该函数使用过程中的参数有可能是空值(null)
      

  5.   

    Public Function showreply(ByVal a As String)
            Dim aa As String
            If a="" then
                aa = "未回复"
            Else
                aa = "已回复"
            End If
            Return aa
        End Function
      

  6.   

    是不是参数定义的时候出现错误
    ByVal a As String
    因为实际输入参数可能是空值(null),如果是这个问题的话应该怎么改
      

  7.   

    用isnothing判断出来的不正确,我数据库中明明是空值(NULL)但是返回的还是false
      

  8.   

    用if a="" then,這樣也不行嗎?
      

  9.   

    不行啊,如果a是空值的情况它是不是就不能用a=""表示了,如果用楼上的方法提示错误
    运算符对 类型“DBNull” 和 字符串“” 无效。
      

  10.   

    Public Function showreply(ByVal a As String)
            Dim aa As String
            If a=noting or a="" then
                aa = "未回复"
            Else
                aa = "已回复"
            End If
            Return aa
        End Function
      

  11.   

    noting 改为 nothing  键盘误!
      

  12.   

    返回错误:运算符对 类型“DBNull” 和 'Nothing' 无效。提示:我这里的实际输入的参数A可能是空值(null)
      

  13.   

    if IsDBNull(aaa) then
     bbb="未回复"
    else
    bbb="已经回复"
    end if