TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

<< Back to VBNET

VB.NET Chr Function: Get Char From Integer

Call the Chr built-in Function to get a Char from an Integer.
Chr deals with Integers and Chars. You must convert your Integer into a Char in your VB.NET program. By using the Chr function, you can take an Integer that represents a specific character and then acquire the actual Char value.IntegerChar
Example. First, this program declares three local variables. The first variable c is assigned to the character "x". The second variable i is set to the ASCII value underlying the "x". And h shows how to convert an integer back into a character.

Important: The program gets a Char from an Integer. This is useful for calling methods that require Char.

VB.NET program that uses Chr function Module Module1 Sub Main() Dim c As Char = "x"c ' Input character. Dim i As Integer = Asc(c) ' Convert to ascii integer. Dim h As Char = Chr(i) ' Convert ascii integer to char. Console.WriteLine(c) Console.WriteLine(i) Console.WriteLine(h) End Sub End Module Output x 120 x
The letter "x". You can see that the ASCII representation for "x" is equal to 120. Then, the character representation (Chr) of 120 is equal to "x". So Asc and Chr can be used to reverse each other's effects on a value.

Tip: The Asc and Chr functions are not available in the C# language. They are only useful in VB.NET programs.

Summary. Here, we showed how you can use Asc and Chr to manipulate ASCII integers for characters in the VB.NET language. In some algorithms, the Integer representation of a Char is more useful.

And: You can use Asc and Chr in these cases to simplify your program. More information on Val and Asc is available.

Val, Asc
© TheDeveloperBlog.com
The Dev Codes

Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf