When working with PHP I always declared my string variable and set them equal to null just to be safe. I’m new to visual basic and am wondering what the safest way to declare a string variable is. Will
Dim strWords As String
be sufficient? Or is it better to set it to null or nothing or some other default value or primitive type?
By default, strWords will be
Nothingby default anyway.Rather than ensuring this value is never nothing by setting a value when declaring the variable, you should ensure your code doesn’t leave the possibility of
strWordsbeing Nothing, and if it is, dealing with it appropriately.If you need to check whether a string is not empty or nothing, you can do: