VB6 equivalent of string.IsNullOrEmpty

后端 未结 7 1427
野趣味
野趣味 2020-12-29 20:40

I\'m doing some work on a legacy application, and my VB6 skills aren\'t that great. I need to check whether a String field has been initialized and set to something other th

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-29 21:00

    use Is Null for stings or is nothing for objects

    use len("string") instead of "string"="" because it is faster

    Dim s As String
    
    If Not (s Is Null) Then
      MsgBox "SET"
    
      if (len(s)>0) then
        MsgBox "size > 0"
      else
        MsgBox "size = 0"
      end if
    Else
      MsgBox "not SET"
    End If
    

    regards

提交回复
热议问题