ARTICLE
How to define variables inside the if statement in Vb.Net
In this article I am trying to explain all of you that how you define variables also inside the if statement in Vb.Net
As all of you now what is the variables and how
to declare or define the variables and as also you now that the if statement
means the simple If...Else is very common across many programming
languages. But the syntax is different in mostly languages like in Vb.Net the
syntax is:
IF
(predicate or Consequent)
Else
(alternative)
When an interpreter finds an If it evaluates
that condition with the given parameters by through variables, functions etc.
Through a simple example I shows you that how
to define a variable inside the If statement the example is given below:
Example
Module Module1
Public Class Test
Public Shared Sub
Main()
Dim value As Boolean
= True
If value Then Dim
txt As String
= "Mamish"
: Console.WriteLine(txt)
Else
_
Dim txt As String
= "Harish"
: Console.WriteLine(txt)
Console.ReadLine()
End Sub
End Class
End Module
OUTPUT

CONCLUSION
I hope this short article helps you to learn
that how to define variables inside the if statement.