C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
VB.NET program that uses Char Dim
Module Module1
Sub Main()
' Char variable.
Dim c As Char = "P"
' Test it.
If c = "P" Then
Console.WriteLine(True)
End If
End Sub
End Module
Output
True
Tip: To do that, you would need a Char array or a StringBuilder for a mutable character buffer.
Char ArrayStringBuilderVB.NET program that uses Char in String
Module Module1
Sub Main()
' String variable.
Dim s As String = "The Dev Codes"
' Char variable.
Dim c As Char = "D"c
' Test first character of String.
If c = s(0) Then
Console.WriteLine("First character is {0}", c)
End If
End Sub
End Module
Output
First character is D
Here: In this program, there is no difference between the two. Both of the built-in functions have the same effect.
VB.NET program that converts Char to Integer
Module Module1
Sub Main()
Dim a As Char = "a"
Dim b As Char = "b"
Dim i As Integer = Asc(a)
Dim i2 As Integer = AscW(b)
Console.WriteLine(i)
Console.WriteLine(i2)
End Sub
End Module
Output
97
98
Note: Despite this, compatibility and correctness are most important in a VB.NET program.