PDA

View Full Version : macro assistance needed...temp convert



klobes01
12-22-2007, 09:40 PM
Hello,





I have a tricky problem.



I have a query which pulls data into about 13 columns. The query works fine, but I am unable to do one thing to the data.



column 10 has hexadecimal values in the format:'XX XX XX XX' and I need to do this:



Where column 3 does not equal 'Odometer' take the value in column 10 convert to binary (I believe its using the #CONH command) and based on a chart(I have the chart of 16 possible binary combinations on the second nibble) then translate from those 16, that first byte in the binary value to a letter and insert the rest of the binary value next to that.



for example, if column 3 does not contain the word 'Odometer', then take the value in column 10 and translate to a 5 digit value which will go in column 11, but leave the value in column 10 alone.



for example, and I realize I need to add the chart.



value 'D8 20 00 99' converts to U1820 in column 11 and replaces the text already in column 11.



The way this translates is that D8 20 00 99 is

11011000001000000000000010011001 in binary



I need to take the value in the first nibble of 1101, lookup the value on a chart and then depending on 16 possible combinations put the value...which in this case is U then with the first value being U, I need to add the fact that since in hex D is either 10 or greater, take the 1 from 10 and add it to the 8 20 from the rest of the 1st two bytes, making the final value D1820. I am racking my brains on how to do this.

Bob Phillips
12-23-2007, 07:55 AM
This is a VBA forum, I don't think #CNH is VBA.