Solved

Text To Html

Posted on 1998-01-04
4
227 Views
Last Modified: 2012-06-27
The following code is working proberly. The only problem is that if a string is 20 chars long, this function will only return the 20 first chars of the translated string.

Example:
Input  = "der var en gang"
Output = "der var&nb"


Function TextAsHTML2(TextToConvert As String)
 Dim N, I As Long
 Dim FoundOne As Boolean
 Dim ExtChar, HTML As Variant
 Dim strTextBuffer As String
 '
 'Special
 'Ext Lowercase
 'Ext Uppercase
 HTML = Array("­", " ", "©", "®", "™", "—", "–", "¹", "²", "³", "¶", "·", "«", "»", "¼", "½", "¾", "£", _
              "á", "â", "æ", "à", "å", "ã", "ä", "ç", "é", "ê", "è", "ð", "ë", "í", "î", "ì", "ï", "ñ", "ó", "ô", "ò", "ø", "õ", "ö", "ß", "þ", "ú", "û", "ù", "ü", "ý", "ÿ", _
              "Á", "Â", "Æ", "À", "Å", "Ã", "Ä", "Ç", "Ð", "É", "Ê", "È", "Ë", "Í", "Î", "Ì", "Ï", "Ñ", "Ó", "Ô", "Ò", "Ø", "Õ", "Ö", "Þ", "Ú", "Û", "Ù", "Ü", "Ý")
 '
 ExtChar = Array("shy", "nbsp", "copy", "#174", "#153", "#151", "#150", "#185", "#178", "#179", "#182", "#183", "#171", "#187", "#188", "#189", "#190", "#163", _
                 "aacute", "acirc", "aelig", "agrave", "aring", "atilde", "auml", "ccedil", "eacute", "ecirc", "egrave", "eth", "euml", "iacute", "icirc", "igrave", "iuml", "ntilde", "oacute", "ocirc", "ograve", "oslash", "otilde", "ouml", "szlig", "thorn", "uacute", "ucirc", "ugrave", "uuml", "yacute", "yuml", _
                 "Aacute", "Acirc", "AElig", "Agrave", "Aring", "Atilde", "Auml", "Ccedil", "ETH", "Eacute", "Ecirc", "Egrave", "Euml", "Iacute", "Icirc", "Igrave", "Iuml", "Ntilde", "Oacute", "Ocirc", "Ograve", "Oslash", "Otilde", "Ouml", "THORN", "Uacute", "Ucirc", "Ugrave", "Uuml", "Yacute")
 '
 strTextBuffer = ""
 '
 For I = 1 To Len(TextToConvert)
  FoundOne = False
  For N = 1 To UBound(HTML)
   If Mid(TextToConvert, I, 1) = HTML(N) Then
     strTextBuffer = strTextBuffer & "&" & ExtChar(N) & ";"
     FoundOne = True
     Exit For  'no reason to continue if we find one.
   End If
  Next N
  If Not FoundOne Then strTextBuffer = strTextBuffer & Mid(TextToConvert, I, 1)
 Next I
 '
 TextAsHTML2 = strTextBuffer
 '
End Function
0
Comment
Question by:jfl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 8

Expert Comment

by:mrmick
ID: 1449165
Your function works fine.  Try this, put at the beginning of  the Form_Load event of the main form:

   Debug.Print TextAsHTML2("der var en gang")
   Stop

and test...
0
 

Author Comment

by:jfl
ID: 1449166
I tried that, but I only get "Stop statement encountered" from a message box.
0
 
LVL 8

Accepted Solution

by:
mrmick earned 20 total points
ID: 1449167
The answer is in your immeadiate window!

Try this instead then:

MsgBox "The HTML is:" & TextAsHTML2("der var en gang")

0
 

Author Comment

by:jfl
ID: 1449168
Thanks!

I have one comment, if anyone would like to use the code don't make it replace your " " with " ". Your webpage will look very funny!

Are you always online mrmick?

I have posted a new question called "SearchWords".
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SLMGR Switches Are Not Working On KMS Host 3 170
which modules are active in VB6 project? 6 57
backup program with robocopy 6 91
2 Global Vars, 1 List Box 4 32
I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question