Results 1 to 8 of 8

Thread: HTML to BBcode

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    HTML to BBcode

    Hi guys,

    I was wondering if any of you know if there is a vb6 code available .. like this one :

    Code:
    http://www.stumbleupon.com/toolbar/#topic=Forums&url=http%253A%252F%252Fwww.seabreezecomputers.com%252Fhtml2bbcode%252F
    I think its pretty tricky

    Any ideas on how to start?

    Cheers
    Thanks for helping me out.

  2. #2
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: HTML to BBcode

    Suggestion: Right Click on that web page and click on view source. Press Ctrl+F and type"function convert()" in that. Here you will see the code to convert html to bbcode. understand the logic and implement it in vb
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  3. #3
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: HTML to BBcode

    IT is aint complicated at all, simply uses some instr() (vb6 equialent) to find tags, then it simply replaces them by the predefined ways.

    Code:
    'JS
    pos = fonttext.indexOf("<FONT", pos);
    
    'VB6
    Dim Pos as Long
    pos = InStr(pos, fonttext, "<FONT", vbTextCompare)
    You can use it to understand how it works, then simply port it to vb6 if you wish.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: HTML to BBcode

    Thanks for replying guys...

    Im gonna star to test thaat now!

    Thanks!


    I'll let you know how i did
    Thanks for helping me out.

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: HTML to BBcode

    well i tried now to use the Replace function..that seems good too...but stilli find it kinda tricky to do this :

    <img src="url"

    so i can replace <img src to [img] but i want to replace that particular " to [/img]

    and if i replace all " with [/img] i wont get far :S
    Thanks for helping me out.

  6. #6
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: HTML to BBcode

    Thats why you have to follow the js code, and implement the Instr(), that is simply walks thru each tags, so you can find out what is the closing tag is needed, because you already know what was the previous tag that opened.


    If PrevTag = 1 Then 'IMG was
    AddTag "[/img]"
    ElseIf PrevTag = 2 Then 'A link
    AddTag "[/url]"
    ElseIf ...

    and so on..

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2008
    Posts
    353

    Re: HTML to BBcode

    I got the entire code...java

    Code:
    http://www.seabreezecomputers.com/html2bbcode/
    I dont get this:
    vb Code:
    1. bbcodetext = bbcodetext.replace(/ BORDER=[^\'\">]*[\'\">]/gi, "");

    Its kinda hard to translate to vb hmmm
    Thanks for helping me out.

  8. #8
    Frenzied Member Jim Davis's Avatar
    Join Date
    Mar 2001
    Location
    Mars base one Username: Jim Davis Password: yCrm33
    Posts
    1,284

    Re: HTML to BBcode

    bbcodetext is a string, and bbcodetext.replace() executes a replace function by using the string. in vb6 :

    bbcodetext = replace$(bbcodetext,...)

    The other part, is seems to me RegExp, that i not use at all, however there is support for regexp in vb6 by using a specific microsoft component.

    An example, how to create a function that accepts pattern, and does some search/matchings. http://www.vbforums.com/showpost.php...23&postcount=5
    Another example for regexp search. http://www.vbforums.com/showpost.php...37&postcount=5

    With by applying some modifications, you can do replaces based on regexp.

    Here is a reference, to understand javascript regexp syntax: http://www.w3schools.com/jsref/jsref_obj_regexp.asp
    Last edited by Jim Davis; Feb 22nd, 2009 at 11:04 AM.

Posting Permissions

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



Click Here to Expand Forum to Full Width