By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,060 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

convert integer to hex, get the endianness right and pad the numbers out

P: 2
I am trying to write to some memory and I am having some trouble because of the endianness of the memory and it being written in Hex. for the first three bytes, if I want to write to them I need to include the string "0000" "0100" "0200" in my command string. I'd just like to be able to have some code like

for dim counter as integer = 0 to 255

*** convert counter to hex *****

myfunction(hexstring)

next


any help would be great!
Sep 9 '13 #1
Share this Question
Share on Google+
1 Reply


P: 2
solved my own problem:

Expand|Select|Wrap|Line Numbers
  1. Dim Num As Int16 = 1
  2.         Dim array As Byte() = BitConverter.GetBytes(Num)
  3.         Dim output As String = BitConverter.ToString(array, 0)
  4.         Dim outputarray() As String = Split(output, "-")
  5.         output = outputarray(0) & outputarray(1)
output then contains what I want!
Sep 10 '13 #2

Post your reply

Sign in to post your reply or Sign up for a free account.