Results 1 to 4 of 4
  1. #1
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61

    PHP to VBA

    Code:
    $lines gzfile('http://en50.tribalwars.net/map/ally.txt.gz');
    if(!
    is_array($lines)) die("File could not be opened");


    foreach(
    $lines as $line) {
        list(
    $id$name,$x$y$player$points$rank) = explode(','$line);
        
    $name urldecode($name);

        
    $name addslashes($name);
        
    mysql_query("INSERT INTO village SET id='$id', name='$name', x='$x', y='$y',
            player='
    $player', points='$points', rank='$rank'");

    Would anyone know how to convert this to VBA?

    ~Matt

  2. #2
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    you have to find common ground, my friend. for example explode() in PHP is the same as split() in visual basic. however, most features of internal functions in PHP are not available in visual basic, for obvious reasons.

    thus, you have to take it a step at a time:

    ***isarray() = there is no vb equivalent so you have to find common ground for a string and decode it that way using multiple vb functions. arrays in vb can be type-caste, and they can be static or dynamic. you might be able to use the functions LBOUND() or UBOUND() on a variable and check for a resulting error. if error, then the var would NOT be an array.

    ***list() is obvious.

    ***vb has no encoding/decoding or hashing functions like PHP, so you have to statically replace url strings that are ASCII-encoded by default. such as %, #, etc...

    ***as with #3, same with addslashes().

  3. #3
    Subwind is offline Can Only Learn
    Windows XP Access 2010 32bit
    Join Date
    May 2012
    Location
    Portsmouth, UK
    Posts
    61
    Quote Originally Posted by help_me_with_access View Post
    you have to find common ground, my friend. for example explode() in PHP is the same as split() in visual basic. however, most features of internal functions in PHP are not available in visual basic, for obvious reasons.

    thus, you have to take it a step at a time:

    ***isarray() = there is no vb equivalent so you have to find common ground for a string and decode it that way using multiple vb functions. arrays in vb can be type-caste, and they can be static or dynamic. you might be able to use the functions LBOUND() or UBOUND() on a variable and check for a resulting error. if error, then the var would NOT be an array.

    ***list() is obvious.

    ***vb has no encoding/decoding or hashing functions like PHP, so you have to statically replace url strings that are ASCII-encoded by default. such as %, #, etc...

    ***as with #3, same with addslashes().
    Thank you for the speedy reply. The urlEncode part I already have a module for this, so it's the other parts I need to find. I will do some research when I get home.

    ~Matt

  4. #4
    help_me_with_access is offline help_me_with_excel
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    262
    did you actually write the php yourself? if you didn't, find function definitions here:

    http://php.net/

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums