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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will aim to show you how simple is making a small application in WhizBase, how to add, remove and update data in the DB. I will make a small address book application where you can add, browse, update and remove addresses. I wi…
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The viewer will learn how to dynamically set the form action using jQuery.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

828 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