VB.Net program to check a string is empty or not using IsNothing() function

Here, we are going to learn how to check a string is empty or not using IsNothing() function in VB.Net?
Submitted by Nidhi, on January 07, 2021 [Last updated : March 07, 2023]

Checking an empty string in VB.Net

Here, we will use IsNothing() function to check a string is empty or not.

Program/Source Code:

The source code to check a string is empty or not using IsNothing() function is given below. The given program is compiled and executed successfully.

VB.Net code to check a string is empty or not using IsNothing() function

'Vb.Net program to check a string is empty or not 
'using IsNothing() function.

Module Module1
    Sub Main()
        Dim name As String
        Dim ret As Boolean

        ret = IsNothing(name)

        If (ret = True) Then
            Console.WriteLine("String Name is empty")
        Else
            Console.WriteLine("Name is: {0}", name)
        End If
    End Sub
End Module

Output

String Name is empty
Press any key to continue . . .

Explanation

In the above program, we created a module Module1 that contains a Main() function.

The Main() function is the entry point for the program. Here, we created a variable of string type, and then check the value of the string is empty or not. Then print an appropriate message on the console screen.

VB.Net String Programs »





Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.