Home »
VB.Net »
VB.Net Programs
VB.Net program to check a string is empty or not using IsNothing() function
By Nidhi Last Updated : October 13, 2024
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 »