Solved

VB: Why is this not working ?

Posted on 1997-11-30
3
133 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

18 Experts available now in Live!

Get 1:1 Help Now