ADVERTISEMENT
ADVERTISEMENT
Code Snippets VB.Net

VB.Net - Get ASCII Value of a Character.

IncludeHelp VB.Net 14 OCT 2016

ADVERTISEMENT

In this VB.Net code we will learn how to get ASCII value of any character in VB.Net?

In this example there is a form with textbox and button control, character will be entered in textbox and will print ASCII value in message box on button click event.

To convert character into its equivalent ASCII value Convert.ToByte() can be used.

Convert.ToByte(character): This function will return ASCII Value of given character.

VB.Net Code - Get ASCII value of any character

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim charValue As Char

        'getting single character from textbox
        charValue = CChar(TextBox1.Text.Trim)

        'getting byte as ascii value of the character
        Dim asciiValue As Integer

        asciiValue = Convert.ToByte(charValue)

        'printing value

        MsgBox("ASCII value is: " & asciiValue)

    End Sub
End Class

Output

character to byte, ascii conversion in vb.net

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.