GreyHairOldGuy
New Member
I feel pretty dumb - you guys are obviously so far above me in programming........
..........I got my printout in hex working, thanks to Ian and others.
My first approach was VERY crude, but it worked.
I would really appreciate some ideas on how YOU would do it.
ALSO
I am now trying to create my first function and after working on it all day, I am still stuck on the first line.
I come in with an 8 bit byte and leave with a 16 bit word.
I can either define the byte or the word but cannot seem to figure out how to define both.
(Please promise not to laugh) My code is below:
'=========================================================
'FUNCTIONS - FUNCTIONS - FUNCTIONS - FUNCTIONS - FUNCTIONS
'=========================================================
Function hextodsp(wout As Word) As Word, (binx As Byte) As Byte
Dim xhi As Byte
Dim xlo As Byte
xhi = binx Mod 16
If xhi = 0x0 Then wout.HB = 0x30
If xhi = 0x1 Then wout.HB = 0x31
If xhi = 0x2 Then wout.HB = 0x32
If xhi = 0x3 Then wout.HB = 0x33
If xhi = 0x4 Then wout.HB = 0x34
If xhi = 0x5 Then wout.HB = 0x35
If xhi = 0x6 Then wout.HB = 0x36
If xhi = 0x7 Then wout.HB = 0x37
If xhi = 0x8 Then wout.HB = 0x38
If xhi = 0x9 Then wout.HB = 0x38
If xhi = 0xa Then wout.HB = 0x41
If xhi = 0xb Then wout.HB = 0x42
If xhi = 0xc Then wout.HB = 0x43
If xhi = 0xd Then wout.HB = 0x44
If xhi = 0xe Then wout.HB = 0x45
If xhi = 0xf Then wout.HB = 0x46
xlo = binx / 16
If xlo = 0x0 Then wout.LB = 0x30
If xlo = 0x1 Then wout.LB = 0x31
If xlo = 0x2 Then wout.LB = 0x32
If xlo = 0x3 Then wout.LB = 0x33
If xlo = 0x4 Then wout.LB = 0x34
If xlo = 0x5 Then wout.LB = 0x35
If xlo = 0x6 Then wout.LB = 0x36
If xlo = 0x7 Then wout.LB = 0x37
If xlo = 0x8 Then wout.LB = 0x38
If xlo = 0x9 Then wout.LB = 0x38
If xlo = 0xa Then wout.LB = 0x41
If xlo = 0xb Then wout.LB = 0x42
If xlo = 0xc Then wout.LB = 0x43
If xlo = 0xd Then wout.LB = 0x44
If xlo = 0xe Then wout.LB = 0x45
If xlo = 0xf Then wout.LB = 0x46
End Function
..........I got my printout in hex working, thanks to Ian and others.
My first approach was VERY crude, but it worked.
I would really appreciate some ideas on how YOU would do it.
ALSO
I am now trying to create my first function and after working on it all day, I am still stuck on the first line.
I come in with an 8 bit byte and leave with a 16 bit word.
I can either define the byte or the word but cannot seem to figure out how to define both.
(Please promise not to laugh) My code is below:
'=========================================================
'FUNCTIONS - FUNCTIONS - FUNCTIONS - FUNCTIONS - FUNCTIONS
'=========================================================
Function hextodsp(wout As Word) As Word, (binx As Byte) As Byte
Dim xhi As Byte
Dim xlo As Byte
xhi = binx Mod 16
If xhi = 0x0 Then wout.HB = 0x30
If xhi = 0x1 Then wout.HB = 0x31
If xhi = 0x2 Then wout.HB = 0x32
If xhi = 0x3 Then wout.HB = 0x33
If xhi = 0x4 Then wout.HB = 0x34
If xhi = 0x5 Then wout.HB = 0x35
If xhi = 0x6 Then wout.HB = 0x36
If xhi = 0x7 Then wout.HB = 0x37
If xhi = 0x8 Then wout.HB = 0x38
If xhi = 0x9 Then wout.HB = 0x38
If xhi = 0xa Then wout.HB = 0x41
If xhi = 0xb Then wout.HB = 0x42
If xhi = 0xc Then wout.HB = 0x43
If xhi = 0xd Then wout.HB = 0x44
If xhi = 0xe Then wout.HB = 0x45
If xhi = 0xf Then wout.HB = 0x46
xlo = binx / 16
If xlo = 0x0 Then wout.LB = 0x30
If xlo = 0x1 Then wout.LB = 0x31
If xlo = 0x2 Then wout.LB = 0x32
If xlo = 0x3 Then wout.LB = 0x33
If xlo = 0x4 Then wout.LB = 0x34
If xlo = 0x5 Then wout.LB = 0x35
If xlo = 0x6 Then wout.LB = 0x36
If xlo = 0x7 Then wout.LB = 0x37
If xlo = 0x8 Then wout.LB = 0x38
If xlo = 0x9 Then wout.LB = 0x38
If xlo = 0xa Then wout.LB = 0x41
If xlo = 0xb Then wout.LB = 0x42
If xlo = 0xc Then wout.LB = 0x43
If xlo = 0xd Then wout.LB = 0x44
If xlo = 0xe Then wout.LB = 0x45
If xlo = 0xf Then wout.LB = 0x46
End Function