Results 1 to 4 of 4
  1. #1
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    custom format (vb6)

    Hi All,
    I've got a bit of vb code in a dll. I thought everything was working well, but I've found out that it is formatting or not formatting a particular string correctly on one computer and not on another. The line is:

    Format(Hex$(bpMacAddr(cnt)), "00")

    In the "is working" instance it will take a hex number, say e, and will turn it to 0e.
    In the "not working" instance it will take the same hex number and leave it as e.
    This causes a lot of problems when I am trying to put together a MAC address and will return 00-0e-.....when working and returns 00-e-.....when it is not.

    Why would this be so and how can I get around this.
    Thank you.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: custom format (vb6)

    The result of Hex$ is a text string, not a number, so you cannot expect formatting it as "00" to work consistently. Try this:

    Right$("00" & Hex$(bpMacAddr(cnt)), 2)

  3. #3
    4 Star Lounger
    Join Date
    Jan 2002
    Location
    Brookings, South Dakota, USA
    Posts
    449
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: custom format (vb6)

    Hi Hans,
    Thank you.
    <hr>expect formatting it as "00" to work consistently<hr>
    Could you explain why it is not consistent? I knew that I was working with strings but I still thought I'd be able to format in the manner that I did thinking that if there were no character the formatting would be "forced" to place a zero there. After all it did work on the machine I developed it on, just not on the machine it was supposed to have worked on.
    Thanks for a solution as well.

    gdr
    <IMG SRC=http://www.wopr.com/w3tuserpics/gdrezek_sig.jpg>
    "Those who dance are considered insane by those who can't hear the music" - George Carlin

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: custom format (vb6)

    In fact, I don't know why it worked at all. A format such as "00" is a number format, not a text format. The result of Hex$ is text, not a number, so there is no reason why a number format should work.

Posting Permissions

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