Bobby
Bobby

Reputation: 659

VB.net Decimal to Hex conversion

I am using the code below to convert decimal to hex.

intPatternColorsRed(1)=255 I get "FF" which is good

intPatternColorsRed(1)=0 I get "0" but I need "00"

Can I format the output to use a placeholder so I alway get a 2 digit return

'//Convert Dec to Hex
strData(0) = intPatternColorsRed(1).ToString("x")            

Upvotes: 0

Views: 946

Answers (1)

Rob
Rob

Reputation: 3853

strData(0) = intPatternColorsRed(1).ToString("X2")

ref: https://msdn.microsoft.com/en-us/library/dwhawy9k(v=vs.110).aspx

Upvotes: 1

Related Questions