Solved

VB: Why is this not working ?

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


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.
    Else
     TekstAsHTML = TekstAsHTML + Mid(s, N, 1)
   End If
  Next N
 Next I
 
End Function
0
Comment
Question by:jfl
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
julio011597 earned 50 total points
ID: 1831488
Maybe:

--//--
For I = 1 To strLength
  For N = 1 To 128
    If Mid(s, I, 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.'
    Else
      TekstAsHTML = TekstAsHTML + Mid(s, I, 1)
    End If
  Next N
Next I
--//--

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

Author Comment

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

Expert Comment

by:julio011597
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).
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

864 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now