Stan Mathews

01-08-2002, 12:19 PM

Don't really know why I started trying to do this, but it seems to work.

Function in body of post and in attachment.

function dectohex as C(dec as N)

‘ By Stan Mathews

‘ Public domain 2002

‘ Last update 1/8/02

dectohex = "" ' Set value to return (null) if input test fails

if round(dec,0) dec

ui_msg_box("Invalid input","Hex conversion not defined for fractional values",UI_OK+UI_ATTENTION_SYMBOL)

end if

dim global manip[255] as N

dim global blb as C

dim global mess as n

mess = dec

blb = ""

i = 0

while (mess/16)> 1

i = i + 1

manip[i] = mod(mess,16)

mess = floor(mess/16)

end while

fstchar = case(mod(mess,16)=0,"0",mod(mess,16)=1,"1",mod(mess,16)=2,"2",mod(mess,16)=3,"3",mod(mess,16)=4,"4",mod(mess,16)=5,"5",mod(mess,16)=6,"6",mod(mess,16)=7,"7",mod(mess,16)=8,"8",mod(mess,16)=9,"9",mod(mess,16)=10,"A",mod(mess,16)=11,"B",mod(dec,mess)=12,"C",mod(mess,16)=13,"D",mod(mess,16)=14,"E",mod(mess,16)=15,"F")

if i > 0

for m = i to 1 step -1

blb = blb + case(manip[m]=0,"0",manip[m]=1,"1",manip[m]=2,"2",manip[m]=3,"3",manip[m]=4,"4",manip[m]=5,"5",manip[m]=6,"6",manip[m]=7,"7",manip[m]=8,"8",manip[m]=9,"9",manip[m]=10,"A",manip[m]=11,"B",manip[m]=12,"C",manip[m]=13,"D",manip[m]=14,"E",manip[m]=15,"F")

next m

end if

dectohex = fstchar + blb

end function

Function in body of post and in attachment.

function dectohex as C(dec as N)

‘ By Stan Mathews

‘ Public domain 2002

‘ Last update 1/8/02

dectohex = "" ' Set value to return (null) if input test fails

if round(dec,0) dec

ui_msg_box("Invalid input","Hex conversion not defined for fractional values",UI_OK+UI_ATTENTION_SYMBOL)

end if

dim global manip[255] as N

dim global blb as C

dim global mess as n

mess = dec

blb = ""

i = 0

while (mess/16)> 1

i = i + 1

manip[i] = mod(mess,16)

mess = floor(mess/16)

end while

fstchar = case(mod(mess,16)=0,"0",mod(mess,16)=1,"1",mod(mess,16)=2,"2",mod(mess,16)=3,"3",mod(mess,16)=4,"4",mod(mess,16)=5,"5",mod(mess,16)=6,"6",mod(mess,16)=7,"7",mod(mess,16)=8,"8",mod(mess,16)=9,"9",mod(mess,16)=10,"A",mod(mess,16)=11,"B",mod(dec,mess)=12,"C",mod(mess,16)=13,"D",mod(mess,16)=14,"E",mod(mess,16)=15,"F")

if i > 0

for m = i to 1 step -1

blb = blb + case(manip[m]=0,"0",manip[m]=1,"1",manip[m]=2,"2",manip[m]=3,"3",manip[m]=4,"4",manip[m]=5,"5",manip[m]=6,"6",manip[m]=7,"7",manip[m]=8,"8",manip[m]=9,"9",manip[m]=10,"A",manip[m]=11,"B",manip[m]=12,"C",manip[m]=13,"D",manip[m]=14,"E",manip[m]=15,"F")

next m

end if

dectohex = fstchar + blb

end function