Running Code within Text

  • 15 years ago

    Hello


    The title doesn't make much sense but i didn't know what to title it.


    I am trying to run some code within html text
    Here is an example

    Code:
    <B>This HTML is included</B>

    If A = B Then


    <I>Some HTML</I>

    ElseIf A = 0 Then


    <I>Some More HTML</I>

    Else


    <I>Some More HTML for else

    End If



    I want to be able to run the code on the lines that start with the harsh (#) and include the html that is between the bits of code.


    Thanks for your help

  • 15 years ago

    Are you trying to develop a web server engine here?

  • 15 years ago

    hello


    No, not really, i just want a few basic features for my themes for my web site


  • 15 years ago

    then, shouldn't this be ASP??

  • 15 years ago

    is this program running within a vb program and outputting some text? or is it actually wanting to work within a webpage if so like what jacky_cheecheo said use asp and the tags <% if blah blah %>

  • 15 years ago

    It runs in VB and outputs the html. I was looking at trying to use ASP code in vb but i haven't found a way.
    I tried the execute function in asp to see how it works, but it only works with the code not including the html and the asp tags; Also i don't know how i would call it through vb.
    If you have any ideas then please tell me.


    Thanks for your time

  • 15 years ago

    still kinda confused a little, so your just trying a simple if else statement in vb and wanting to export the html depending on the situation in , are u exporting to a file, as the if statment is right well without the #, save the data to a string like


    StringHTML = "<html>" & vbnewline & "<body>"
    if A= A THEN
    StringHTML = StringHTML & "<B>ITS A</B>"
    ELSE
    StringHTML = StringHTML & "<B>NOOO A'S</B>"
    end if
    StringHTML = "StringHTML & VBNEWLINE & "</body>" & vbnewline & "</html>"


    '//SAVE TO TEXT FILE THE StringHTML and launch via shell if wanted to see it working

  • 15 years ago

    That is sorta what i want. I remember there being an eval function somewhere, i might be in the scripting control. I am feeding the html down to the browser from a server, but i am not making a web server it is a web portal that runs in IIS and i want some more control over what is given to the visitor.


    I would have liked it to have more features but i think that asp engine would slow it down anyway.


    If you know how i would do it if there was a string named SiteHTML how would i process the code. I would use either InStr or Left to find the # in the lines and then how would i execute the code?


    Thanks for all your help

  • 15 years ago

    jonorossi,


    correct me if i'm wrong, i think this can be done in the .asp file itself. SInce you're feeding your program with a html file from a webserver, then shouldn't the webserver process the codes (asp) and then your program just load the html streams?

  • 15 years ago

    Hello


    Good idea but it will not work. I am making a Tier-2 component. The ASP page calls the Tier-2 component and gets the page so i cannot get the asp page to execute the code. Any other ideas?


    Thanks

  • 15 years ago

    Hello


    I am just moving this topic back to the main page because i still need help with it.
    If you don't understand what i am trying to do then please ask.


    a simple explaination is to have If statements executed within html.


    Code:
    <B>This HTML is always included</B>
    #If A = B Then
    <I>Some HTML if A = B</I>
    #Else
    <I>Some HTML if A <> B
    #End If


    Please help. Post any ideas you might have, Thanks

  • 15 years ago

    IF its within the html page then it needs to be done with asp asp.net or php, like in asp


    Code:

    StringHTML = "<html>" & vbnewline & "<body>"


    <% if A= A THEN
    StringHTML = StringHTML & "<B>ITS A</B>"
    ELSE
    StringHTML = StringHTML & "<B>NOOO A'S</B>"
    end if %>


    StringHTML = "StringHTML & VBNEWLINE & "</body>" & vbnewline & "</html>"


  • 15 years ago

    Hello


    I am not making a web page. If I was i would ask in the ASP board, i know heaps about asp anyway.
    I will explain it more because people are still not understanding.
    Also there was an error in the code you provided rollershade on the last line, it has an double quote when it should be there at the start and also you should be putting vbNewLine after all the lines.


    Say a wanted to execute a html page with some code in it (refer to my last post) and save this to a text file from a VB app. How would i achieve this. I think that everyone is getting confused whether i wanted a web page or was it in vb.


    If you still don't understand then please state what part you don't understand. Thanks.

  • 15 years ago

    that might still be confusing


    I am not doing this but say i was making an email sender and it allowed you to put code into the email and the email sender would process it before it would send it out. If the email was as follows how would the email sender execute the code before it sent it.


    Code:
    #If Email = "john@hotmail.com" Then
    Hey Mate
    #Else
    Hello
    #End If
    From Me


    OR


    Code:
    <% If Email = "john@hotmail.com" Then %>
    Hey Mate
    <% Else %>
    Hello
    <% End If %>
    From Me

  • 15 years ago

    AHH I THINK IM ON URE WAVE LENGTH Now (doh caps sorry) , u have a html page sya blah.htm now u open it in vb and want to process the vb contents thats in the file and ouput the right results to the file before sending it out or executing it. Is this right? well id say ud have to interpret the contents, ie first find the <% tag and end tag %> then get the contents in a string, u cannot or i havnt seen i should say vb code get executed from a string but if u find it let me know. The easiest would be to make ure own values instead of if else, say u wanted to know if it was a or b make ure app look forthe word


    Word=


    then Or now it can find the word after Word= AND THE wORD after Or so the string u have extracted from the html file was


    <% Word=John/Or=Peter/ %>


    now in the vb part it would look for the word after word= note the / interperate it as the end of the word, then it retrieves the word after Or= NOW MAKE COMPARISON AS U LIKE, 9doh caps againg) and output the results into the new file or however.

  • 15 years ago

    It seems that you are now on the same brain wave length. Good i don't have a non-human brian, lol.


    I would prefer to use simple BASIC syntax because themes with this stuff will be made by many people and i want to keep it simple. So the format with If, ElseIf, Else and End If would be heaps better.


    You can execute vbscript code using the scripting control.
    I was trying to use it but it only executes code so i don't know how i would execute the html w/ code. Unless i modified the html parts to:
    sHTML = sHTML & vbNewLine & Replace(sHTMLLine,"""","""""")
    and the lines starting with the harsh (#) i could run the code from them.
    I think that the scripting control or reference would slow the site down because it would be executed on every page for every visitor and for every refresh. But it would give more power.


    If you have another idea then please post it, Thanks

  • 15 years ago

    actually the code would be


    Code:
    '// Make a reference to the control with sHTML


    If Left(sLine,1) = "#" Then
    sHTML = sHTML & vbNewLine & Mid(sLine,2,Len(sLine) - 1)
    Else
    sHTML = sHTML & vbNewLine & "sHTML = """ & Replace(sHTMLLine,"""","""""") & """"
    End If


    '// Execute sHTML with scripting control

  • 15 years ago

    ill take a look at the scripting control tonight when i get home


    'Good i don't have a non-human brian, lol.' ahhhhhhhhhhhhhhhh

  • 15 years ago

    Hello


    Thanks for all your help, i played around with the scripting control and have made it work. But the only problem is that you cannot create a sub procedure called 'Write' because it is a vb function.


    I wanted to make 'Response.Write' because i made a reference to a class for use in the scripting but i have used 'Response.WriteHTML'. If you think it should be something else then please let me know. Because web masters and theme developers will be using it i would like to make it as close to ClassicASP as possible so if you think it should be something other than 'WriteHTML' then please post.


    Thanks for all your time

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“My definition of an expert in any field is a person who knows enough about what's really going on to be scared.” - P. J. Plauger