Padding hex values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Richard

    #1

    Padding hex values

    I want to pad out a hex value with leading zeros, e.g. I
    don't want 7B I do want 0000007B. The best I can do is
    Return New String("0"c, 8 - Len("7B")) & "7B". Can anyone
    do better?
  • Brian Davis

    #2
    Re: Padding hex values


    Use the PadLeft function of the String class:

    Dim myString as String = "7B"
    Return myString.PadLef t(8,"0")


    Brian Davis



    "Richard" <Richard.Giles@ Stortext.com> wrote in message
    news:027101c376 fa$2788e390$a30 1280a@phx.gbl.. .[color=blue]
    > I want to pad out a hex value with leading zeros, e.g. I
    > don't want 7B I do want 0000007B. The best I can do is
    > Return New String("0"c, 8 - Len("7B")) & "7B". Can anyone
    > do better?[/color]


    Comment

    • Richard

      #3
      Re: Padding hex values

      Good answer. I wish MS were not so cryptic with their
      method names!!![color=blue]
      >-----Original Message-----
      >
      >Use the PadLeft function of the String class:
      >
      >Dim myString as String = "7B"
      >Return myString.PadLef t(8,"0")
      >
      >
      >Brian Davis
      >www.knowdotnet.com
      >
      >
      >"Richard" <Richard.Giles@ Stortext.com> wrote in message
      >news:027101c37 6fa$2788e390$a3 01280a@phx.gbl. ..[color=green]
      >> I want to pad out a hex value with leading zeros, e.g. I
      >> don't want 7B I do want 0000007B. The best I can do is
      >> Return New String("0"c, 8 - Len("7B")) & "7B". Can[/color][/color]
      anyone[color=blue][color=green]
      >> do better?[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...