Results 1 to 6 of 6

Thread: PHP to VB6

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    33

    PHP to VB6

    Hey, I was wondering if someone could help me convert this from PHP to VB script.
    Thanks in advance

    Code:
    foreach($file as $value) {
       $fval .= $value;
    }
    
    if(preg_match_all('/<td><a href="hiscoreuser.cgi?.*&category=.*" class=c>(.*)<\/a><\/td>/', $fval, $matches)) {
       $i = 0;
       foreach($matches as $value) {
           foreach($value as $value) {
               if($i == 1) {
                   $skill[] = $value;
               }
           }
           $i++;
       }
    }
    
    if(preg_match_all('/<td align="right">\n(.*)\n<\/td><td/', $fval, $matches)) {
       $i = 0;
       foreach($matches as $value) {
           foreach($value as $value) {
               if($i == 1) {
                   $level[] = $value;
               }
           }
           $i++;
       }
    }
    
    function skill($sskill) {
       global $skill, $level;
       if(!isset($skill)) {
           return '--';
       }
       else {
           foreach($skill as $key => $value) {
               if($value == $sskill) {
                   return $level[$key];
                   $i = 1;
               }
           }
           if(!isset($i)) {
               return '--';
           }
       }
    }
    
    $overall = skill('Overall');
    $attack = skill('Attack');
    $defence = skill('Defence');
    $strength = skill('Strength');
    $hitpoints = skill('Hitpoints');
    $ranged = skill('Ranged');
    $prayer = skill('Prayer');
    $magic = skill('Magic');
    $cooking = skill('Cooking');
    $woodcutting = skill('Woodcutting');
    $fletching = skill('Fletching');
    $fishing = skill('Fishing');
    $firemaking = skill('Firemaking');
    $crafting = skill('Crafting');
    $smithing = skill('Smithing');
    $mining = skill('Mining');
    $herblore = skill('Herblore');
    $agility = skill('Agility');
    $thieving = skill('Thieving');
    $slayer = skill('Slayer');
    $runecrafting = skill('Runecrafting');

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: PHP to VB6

    Quote Originally Posted by Jonno12345
    Hey, I was wondering if someone could help me convert this from PHP to VB script.
    Thanks in advance

    Code:
     foreach($file as $value) {
        $fval .= $value;
     }
     
     if(preg_match_all('/<td><a href="hiscoreuser.cgi?.*&category=.*" class=c>(.*)<\/a><\/td>/', $fval, $matches)) {
        $i = 0;
        foreach($matches as $value) {
            foreach($value as $value) {
                if($i == 1) {
                    $skill[] = $value;
                }
            }
            $i++;
        }
     }
     
     if(preg_match_all('/<td align="right">\n(.*)\n<\/td><td/', $fval, $matches)) {
        $i = 0;
        foreach($matches as $value) {
            foreach($value as $value) {
                if($i == 1) {
                    $level[] = $value;
                }
            }
            $i++;
        }
     }
     
     function skill($sskill) {
        global $skill, $level;
        if(!isset($skill)) {
            return '--';
        }
        else {
            foreach($skill as $key => $value) {
                if($value == $sskill) {
                    return $level[$key];
                    $i = 1;
                }
            }
            if(!isset($i)) {
                return '--';
            }
        }
     }
     
     $overall = skill('Overall');
     $attack = skill('Attack');
     $defence = skill('Defence');
     $strength = skill('Strength');
     $hitpoints = skill('Hitpoints');
     $ranged = skill('Ranged');
     $prayer = skill('Prayer');
     $magic = skill('Magic');
     $cooking = skill('Cooking');
     $woodcutting = skill('Woodcutting');
     $fletching = skill('Fletching');
     $fishing = skill('Fishing');
     $firemaking = skill('Firemaking');
     $crafting = skill('Crafting');
     $smithing = skill('Smithing');
     $mining = skill('Mining');
     $herblore = skill('Herblore');
     $agility = skill('Agility');
     $thieving = skill('Thieving');
     $slayer = skill('Slayer');
     $runecrafting = skill('Runecrafting');
    What is that? Looks like its for a game called Runescape (I used to play log time agao) had a good character,

    What does the code do?

  3. #3

    Thread Starter
    Member
    Join Date
    Jan 2005
    Posts
    33

    Re: PHP to VB6

    Quote Originally Posted by Pino
    What is that? Looks like its for a game called Runescape (I used to play log time agao) had a good character,

    What does the code do?
    Got it in one


    It parses the data (in this case, peoples levels) from the runescape hiscores and places them into variables. I have seen it used many a time in VB6, but nobody will let on their code So I found a PHP version and can't make head nor tail of it, which is why I need a little help

    Thanks in advance.

  4. #4
    VBA Nutter visualAd's Avatar
    Join Date
    Apr 2002
    Location
    Ickenham, UK
    Posts
    4,906

    Re: PHP to VB6

    Do you want this in VB Script/ASP (VB Script) or VB 6? The barrier here is the use of a regular expression. I can convert the rest of the code for you but implementing the string matching in the regular expressions is very complex without a regular expression parser and I do not have the time to do this.

    I suggest you post a thread in the VB6 or VB Script / ASP forum asking how to use your regular expressions in VB. I have heard that there is a library but have never used it.

    For your information the regular expression is that complex looking string in the preg_match() function:
    Code:
    preg_match_all('/<td><a href="hiscoreuser.cgi?.*&category=.*" class=c>(.*)<\/a><\/td>/', $fval, $matches)
    In this case the regular expression will match the text between the <td><a> tags of the string and dump the result in an array,. i.e. it will match among others:

    <td><a href="hiscoreuser.cgi?value=4563&category=value" calss=c>Some Link Text</a></td>

    <td><a href="hiscoreuser.cgi?value=453663&category=another" calss=c>Some Link Text</a></td>

    <td><a href="hiscoreuser.cgi?value=444&category=someother" calss=c>Some Link Text</a></td>

    The bold areas of the text must always be present for a match to occur. The italic areas can vary. This is the reason they are called regular expressions and would require, character by character analysis of the string in VB.
    PHP || MySql || Apache || Get Firefox || OpenOffice.org || Click || Slap ILMV || 1337 c0d || GotoMyPc For FREE! Part 1, Part 2

    | PHP Session --> Database Handler * Custom Error Handler * Installing PHP * HTML Form Handler * PHP 5 OOP * Using XML * Ajax * Xslt | VB6 Winsock - HTTP POST / GET * Winsock - HTTP File Upload

    Latest quote: crptcblade - VB6 executables can't be decompiled, only disassembled. And the disassembled code is even less useful than I am.

    Random VisualAd: Blog - Latest Post: When the Internet becomes Electricity!!


    Spread happiness and joy. Rate good posts.

  5. #5
    Junior Member
    Join Date
    Apr 2004
    Location
    Stockholm, Sweden
    Posts
    29

    Re: PHP to VB6

    You could use the RegExp object:
    RegExp

    It's been a while since I've used it, so I don't remember if they are PCRE or not, so you may have to rewrite the regexp as seen in the PHP example.
    If there is a way to solve your problems, there is no need to worry; if there is no way to solve your problems, there is no point to worry.

  6. #6
    Fanatic Member
    Join Date
    Jan 2005
    Location
    In front of this pc.
    Posts
    580

    Re: PHP to VB6

    This may be an extraneous post since I'm a few days behind the last one, but...

    I would suggest rewritting the regexp by replacing the "\n" with ".+$". This will allow you to match anything, or nothing, to the end of the line (in case there is added whitespace or another carriage return other than \n).

    Also, you might have to escape the special characters, such as changing "?" to "\?" and "." to "\.", but I'm not sure about that..you would in perl but maybe not in VB script.

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