dcsimg
Results 1 to 5 of 5

Thread: HTML inside a String *problems*

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2007
    Posts
    1

    HTML inside a String *problems*

    So what i need is a program that takes some html code like 9 lines and where ever it find the {@} it replaces it with an increasing number 1,2,3..etc and where it finds {url} it replaces it with an image url that i load into a list box.
    So i got about 500 urls so it generates me 500 html codes. I have provided the code below to see what im doing.

    OK THE PROBLEM - After about 47 - 50 html code outputs (to a text box) it stops outputing code... i tried saving to a text file as well and it outputs all 500 html codes but towards the end of the code it cuts off half of the html. Ok so i output everything to a lits box instead ... it works but again it cuts off half of the html when it gets close to 500


    Code:
    Private Sub Command2_Click()
    Dim html, result, Final As String
    
    html = Text2.Text
    
    Dim b As Integer
    Dim url As String
    Dim a As Integer
    Dim x As Integer
    
    
    a = List1.ListCount
    b = 0
    
    
    
    For x = 0 To a - 1
    
    b = b + 1
    
    url = List1.List(x)
    
    
    result = (Replace(html, "{url}", url))
    Final = (Replace(result, "{@}", b))
    
    
    Text3.Text = Text3.Text + vbNewLine & Final
    
    
    Next x
    
    
    End Sub

    HERES THE HTML that is being replaced

    Code:
    <table border="1" width="100%" id="table1" cellspacing="0" cellpadding="0" bordercolor="#C0C0C0">
    <tr>
    <td>
    <img border="0" src="{url}" width="300" height="150"><br>
    <form name="test{@}">
    <a class="highlighttext" href="javascript:HighlightAll('test{@}.select1')">Select All</a><br>
    <textarea rows="3" cols="64" onfocus="this.select()" style="font-size: 10pt;" readonly="readonly" name="select1"><style type="text/css"> 
    .contactTable {background:url('{url}') 
    no-repeat center; width:300px!important; height:150px!important; 
    padding:0px!important; } 
    .contactTable table, table.contactTable td {padding:0px !important; border:0px 
    none; background-color:transparent; background-image:url('none');} 
    .contactTable a img {visibility:hidden; border:0px!important;} 
    .contactTable a {display:block; height:28px; width:115px;} 
    .contactTable .text {font-size:1px!important;} 
    .contactTable .text, .contactTable a, .contactTable img {filter:none!important;}
    </style>
    <div style="position:absolute;left:0px;top:40px;"><a 
    href="http://www.myspacejunk.net" 
    target="_self"><img src="http://i241.photobucket.com/albums/ff156/myspacejunk_photo/mjbutton.gif" 
    border="0" alt="MySpace Codes" width="75" height="37" /></div></a></textarea></p>
    </form>
    </td>
    </tr>
    </table>
    <br>
    Notice how i have the {@} and {url} for the vb program to replace.

    So when i output to a file or a list box the last 200 html codes look like this all cut off missing the bottom portion:

    Code:
    <table border="1" width="100%" id="table1" cellspacing="0" cellpadding="0" bordercolor="#C0C0C0">
    <tr>
    <td>
    <img border="0" src="{url}" width="300" height="150"><br>
    <form name="test{@}">
    <a class="highlighttext" href="javascript:HighlightAll('test{@}.select1')">Select All</a><br>
    <textarea rows="3" cols="64" onfocus="this.select()" style="font-size: 10pt;" readonly="readonly" name="select1"><style type="text/css"> 
    .contactTable {background:url('{url}') 
    no-repeat center; width:300px!important; height:150px!important; 
    padding:0px!important; } 
    .contactTable table, table.contactTable td {padding:0px !important; border:0px 
    none; background-color:transparent; background-image:url('none');} 
    .contactTable a img {visibility:hidden; border:0px!important;} 
    .contactTable a {display:block; height:28px; width:115px;} 
    .contactTable .text {font-size:1px!important;} 
    .contactTa
    <br>
    ^^^^^ see how its missing stuff? Why does VB do this ? is there a string limitation or something im doing wrong ? Why cant i output this code 500 times into a text box why does it only do it like 47 times and stops, but adding it to the list box works 500 times....


    Help Would be Most Appreciated


    Thank You



    SOLVED PROBLEM by USING RICH TEXT BOX
    Last edited by infowire; Oct 30th, 2007 at 09:08 PM.

  2. #2
    Frenzied Member
    Join Date
    Jul 2007
    Posts
    1,306

    Re: HTML inside a String *problems*

    If your problem is resolved. please mark the thread resolved using Thread Tools
    IIF(Post.Rate > 0 , , )

  3. #3
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: HTML inside a String *problems*

    Infowire,
    I saw your problem was solved, but you can maybe improve speed.
    Because I saw this line
    Code:
    Dim html, result, Final As String
    And what this does, is declaring html and result as variant and final as string.
    You should know that a variant works slower in reading/writing than a string.
    The correct method to do it this way is
    Code:
    Dim html As String, result As String, Final As String
    And btw, do you actually know why the textbox doesn't work?
    Delete it. They just clutter threads anyway.

  4. #4
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,692

    Re: HTML inside a String *problems*

    It sounds as if the string could be getting longer than the maximum string length (or maximum textbox text length) (which is pretty long, but not infinite).
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  5. #5
    Frenzied Member TheBigB's Avatar
    Join Date
    Mar 2006
    Location
    *Stack Trace*
    Posts
    1,511

    Re: HTML inside a String *problems*

    well, depends on what you find long.
    the limit lies at the 64K.
    one may find that short while another long.
    Delete it. They just clutter threads anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width