Unicode to HTML Converter in Visual Basic
Submitted by Yorkiebar on Thursday, May 15, 2014 - 04:09.
Introduction:
This tutorial is on how to create a unicode to HTML equivilient characters.
Design:
This design requires two components;
Textbox, textbox1, User entries
Button, button1, Begins process.
Variables:
The way this system will work is it will search one array or list of information for the entry from the user, get the inex and return the element at the same index but in a different list, the information's equivilient partner. So first we need the two lists, we'll call the user entries list 'entries', and the equivilients list 'eqs'...
I have only included a few unicode & HTML characters, you can add an entire range by performing a simple Google search.
Button Click:
Now, on the button mouse click, we want to retrieve the entered text by the user and store it in a new variable named 'user'...
We then want to find the index in the 'entries' list that matches the users entry, all converted to lower case so there are no minimal discrepancies...
Next we want to use the stored index in the integer variable 'ind' to msgbox out the element at that integer position/index of the 'eqs' list...
Finished!
Here's the full source code:
- Dim entries As String() = {"""", "quote", "£", "pound"}
- Dim eqs As String() = {""", """, "£", "£"}
- Dim user As String = TextBox1.Text
- Dim ind As Integer = Nothing
- For i As Integer = 0 To entries.Count - 1
- If (user.ToLower() = entries(i).ToLower()) Then ind = i
- Next
- If (ind = Nothing) Then
- MsgBox("That unicode character(s) was not found!")
- Else
- MsgBox(eqs(ind))
- End If
- Public Class Form1
- Dim entries As String() = {"""", "quote", "£", "pound"}
- Dim eqs As String() = {""", """, "£", "£"}
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- Dim user As String = TextBox1.Text
- Dim ind As Integer = Nothing
- For i As Integer = 0 To entries.Count - 1
- If (user.ToLower() = entries(i).ToLower()) Then ind = i
- Next
- If (ind = Nothing) Then
- MsgBox("That unicode character(s) was not found!")
- Else
- MsgBox(eqs(ind))
- End If
- End Sub
- End Class
Add new comment
- 89 views