ASCII Generator using VB 6.0
Submitted by donbermoy on Wednesday, March 19, 2014 - 06:12.
ASCII is one of the important functions of a program as it creates shortcut keys when pressed. ASCII stands for American Standard Code for Information Interchange. Computers can only understand numbers, so an ASCII code is the numerical representation of a character such as 'a' or '@' or an action of some sort. Most computers use ASCII codes to represent text, which makes it possible to transfer data from one computer to another. So, in this article we will create a program that can generate ASCII Conversion when a key is pressed.
Now, let's start this tutorial!
1.Let's start this tutorial by following the following steps in Microsoft Visual Basic 6.0: Open Microsoft Visual Basic 6.0, click Choose Standard EXE, and click Open.
2.Next, add two TextBox named Text1 for inputting the pressed key and Text2 for generating the ASCII equivalent of the pressed key. You must design your interface like this:
3. Now put this code for your code module. This code is for Text1_KeyPress:
- This if statement above triggers to empty Text1 and Text2 when the text in Text1 and Text2 are not empty. Meaning to say, it wil only provide one input in Text1 as we have this KeyPress event.
As you have seen, there is a KeyAscii Parameter there in Text1_Keypress. The KeyPress event occurs when any key that corresponds to an ASCII character is pressed. The ASCII character set represents not only the letters, digits, and punctuation on a standard keyboard but also most of the control keys. The keyascii argument returns an integer value corresponding to an ASCII character code. Then, the value of the KeyAscii will be equal to strAscii and it will be hold and displayed in Text2. Next, we have this Select Case statement in which we filter the pressed key of 'Enter', 'Backspace', 'Esc', and 'Spacebar'. Their Case (Integer) corresponds to their pressed key.
- Private Sub Text1_KeyPress(KeyAscii As Integer)
- Dim strKey As String
- Dim strAscii As String
- If Text1.Text <> "" And Text2.Text <> "" Then
- Text1 = "": Text2 = ""
- End If
- strAscii = KeyAscii
- Text2.Text = strAscii
- Select Case strAscii
- Case 13
- Text1.Text = "Enter"
- Case 8
- Text1.Text = "BackSpace"
- Case 27
- Text1.Text = "Esc"
- Case 32
- Text1.Text = "SpaceBar"
- End Select
- End Sub
Explanation:
We have first initialized variable strKey and strAScii As String.- If Text1.Text <> "" And Text2.Text <> "" Then
- Text1 = "": Text2 = ""
- End If
Output:
Download the source code and try it! :) For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below. Best Regards, Engr. Lyndon Bermoy IT Instructor/System Developer/Android Developer/Freelance Programmer Mobile: 09488225971 Landline: 826-9296 E-mail:[email protected] Add and Follow me on Facebook: https://www.facebook.com/donzzsky Visit and like my page on Facebook at: https://www.facebook.com/BermzISwareAdd new comment
- 1134 views