you can try : {0:X4}
Main Topics
Browse All TopicsHi, I'm using VB 2005, WinForms. I have a Hex value that I'm trying to format and cannot get it the way I need it to end up.
My string is below:
strforwardingHTAddress is a String
strHTLength is a String
strEndofHTAddress = Hex$(CLng("&H" & strforwardingHTAddress) + CInt(strHTLength))
I'm getting the correct values, but without any leading zeros. I would like it to be in a format like this 0020A100, not 20A100.
I've tried:
String.Format("{0:X8}", Hex$(CLng("&H" & strforwardingHTAddress) + CInt(strHTLength)))
String.Format("{0:XXXXXXXX
String.Format("{0:X#######
String.Format("{0:00000000
String.Format("{0:########
However, all these approaches drop out the leading zeros.
Any suggestions on how I can solve this?
Thanks,
Fulano
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
From Mr. Fulano's other question:
http://www.experts-exchang
Leave 'em as Strings. You can convert them to Int64s like this:
Dim HexString As String = "0000A10000500000"
Dim HexInt64 As Int64 = Convert.ToInt64(HexString,
Debug.Print(HexString & " Hex = " & HexInt64 & " Decimal")
Now you can perform calculations with them as Int64s.
When you need them back in Hex Format, use something like:
Dim HexString2 As String = HexInt64.ToString("X").Pad
Debug.Print("HexString2 = " & HexString2)
The output was:
0000A10000500000 Hex = 177021377314816 Decimal
HexString2 = 0000A10000500000
Business Accounts
Answer for Membership
by: quicksilver17Posted on 2009-10-31 at 09:31:00ID: 25710344
http://www.builderau.com.a u/program/ dotnet/soa /Easily-fo rmat- strin g-output-w ith-String -Format/ 0, 339028399, 339177160, 00.htm ing-format ting-in-cs harp/ /StringFor mat.aspx om/UploadF ile/Joshy_ geo/ HexCon verter1028 2006021521 AM/HexConv erter.aspx
http://blog.stevex.net/str
http://www.blackwasp.co.uk
http://www.c-sharpcorner.c
hope it helps you