VB: Why is this not working ?

Posted on 1997-11-30
Last Modified: 2013-12-25
The following source creates big files and doesn't change the extended characters.

Function TekstAsHTML(s As String) As String
 Dim N, I, strLength As Long
 Dim HTML As Variant
 HTML = Array("x", "x", "x", "‚", "ƒ", "„", "…", "†", "‡", "ˆ", "‰", "š", "‹", "œ", "x", "x", "x", "x", "‘", "’", "“", "”", "•", "–", "—", "˜", "™", "š", "›", "œ", "x", "x", "ÿ", " ", "¡", "¢", "£", "¤", "¥", "¦", "§", "¨", "©", "ª", "«", "¬", "­", "®", "¯", "°", "±", "²", "³", "´", "µ", "¶", "·", "¸", "¹", "º", "»", "¼", "½", "¾", "¿", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "×", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ß", "à", "á", "â", "ã", "ä", "å", "æ", "ç", "è", "é", "ê", "ë", "ì", "í", "î", "ï", "ð", "ñ", "ò", "ó", "ô", "õ", "ö", "÷", "ø", "ù", "ú", "û", "ü", "ý", "þ", "ÿ")
 Dim varTmp As String
 strLength = Len(s)
 For I = 1 To strLength
  For N = 1 To 128
   If Mid(s, N, 1) = HTML(N) And HTML(N) <> "x" Then
     TekstAsHTML = TekstAsHTML + "&" + (N + 127) + ";"
     Exit For  'ingen grund til at fortsætte hvis vi har fundet en skyldig.
     TekstAsHTML = TekstAsHTML + Mid(s, N, 1)
   End If
  Next N
 Next I
End Function
Question by:jfl
  • 2

Accepted Solution

julio011597 earned 50 total points
ID: 1831488

For I = 1 To strLength
  For N = 1 To 128
    If Mid(s, I, 1) = HTML(N) And HTML(N) <> "x"
      TekstAsHTML = TekstAsHTML + "&" + (N + 127) + ";"
      Exit For 'ingen grund til at fortsætte hvis vi har fundet en skyldig.'
      TekstAsHTML = TekstAsHTML + Mid(s, I, 1)
    End If
  Next N
Next I

I.e., i guess you meant Mid(s, I, 1).

Author Comment

ID: 1831489
I did thanks!, but it's still creating a large file, and doesn't do what it's supposed to do!

Expert Comment

ID: 1831490
That is because logic must be wrong, not implementation.

I guess what you're trying to do is substitute special chars with HTML escape sequences, but i'm not sure about it, because i can see a "&nbsp;" sequence there, and this make me confused.

If you tell me what your task exactly is, i could give an algorithm to work on (i cannot program VB).

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
If you get a (Blue Screen of Death), your system writes a small file called a minidump. Your first step is to make certain your computer is setup to record memory dumps. Right click My Computer, choose properties. Click on the advanced tab, an…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

831 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