Results 1 to 7 of 7

Thread: help with this vb code pls?

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    3

    Exclamation help with this vb code pls?

    Hi there ,

    I am looking in to a source code of yahoo messenger clone in vb6.0 , so obviously its winsock programming

    so in The yahoo messenger header for yahoomessenger packet i see this declaration in the module,
    Code:
    YMSGPacket = "YMSG" & Chr(Int(Version / 256)) & Chr(Int(Version Mod 256)) & String(2, Chr(1)) & Chr(Int(Len(StrPacketType) / 256)) & Chr(Int(Len(StrPacketType) Mod 256)) & Chr(Int(StrComm / 256)) & Chr(Int(StrComm Mod 256)) & Mid(StrStat, 1, 4) & Mid(StrSession, 1, 4) & StrPacketType
    tht code is the code which is sent through the winsock , I have a few more questions ,in what format is data senthrough winsockcomponent of visualbasic , string , hex ,binary or ascii

    i see the mod 256 and / 256 code everywhere in this program , whats use of this statement

    another code

    Code:
    TimSt = Chr$((((number And &HFF000000) / 256) / 256) / 256) & Chr$(((number And &HFF0000) / 256) / 256) & Chr$((number And &HFF00&) / 256) & Chr$(number And &HFF&)
    every help would be greatly appreciated

    thanks in advance

  2. #2
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: help with this vb code pls?

    / 256 is simple division ... 1/4 = .25 4/2 = 2 ... etc.
    mod 256 is a modulo operation, returns the remainder of a division... so 5 mod 3 is 2 4 mod 2 is 0 (2 goes into 4 evenly) 9 mod 3 is also 0, 11 mod 3 is 2 ...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    3

    Re: help with this vb code pls?

    Thanks for the reply sir,ok , i know the operators division and mod,but in the case of this Chr(Int(Version / 256)

    so my question is whats the use of dividing by 256 or getting mod 256 , is to convert string or integer in to one peculiar form

    sorry i am a noob

  4. #4
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: help with this vb code pls?

    Looks like a form of data packing I think... but I'm not sure...

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    14,205

    Re: help with this vb code pls?

    Everything has a use, why it is being done here I do not know.

    In the case of CHR() and Mod 256 it would seem that the goal is to get a number < 256 and convert that to a character in the valid range of 0 - 255

    Same with the division

  6. #6

    Thread Starter
    New Member
    Join Date
    Feb 2012
    Posts
    3

    Re: help with this vb code pls?

    ok thanks to both of you , as i got this code from a yahoo clone project , is there a possibility that this is code is to convert it in to a form yahoo recognises or which is exclusive to yahoo

    btw its a yahoo messenger clone

  7. #7
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: help with this vb code pls?

    Quote Originally Posted by pattrick_george View Post
    ok thanks to both of you , as i got this code from a yahoo clone project , is there a possibility that this is code is to convert it in to a form yahoo recognises or which is exclusive to yahoo
    A good assumption I would think.

    Going back to dividing by 256 multiple times. Data packing, as suggeted, is probably the reason. You can pack quite a bit information in a Long value type (32 bits, 4 bytes). Take an IP address for example, written out: 255.255.255.255 would consist of 15 characters, at 1 byte per character, 15 bytes. A Long value is just 4 bytes. That same value as a Long would be simply negative one & displayed in hex as: FFFFFFFF (where FF = 255). Example: A Long value can contain 4 values, each in the range of 0-255. Each of the 4 "tokens" of that Long are offset by 256. Typically bit masking and integer division is used to extract the 4 bytes of a Long, not real division.

    But to the point now. We can tell you what the code is doing from a logical perspective. However, why it is doing what it is doing is only known to the author and others that are familiar with the target's requirements; that of Yahoo
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

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