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 »



ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT


Comments and Discussions!




Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.