Mine works with every type but floats from all ranges. Here it is converted to a function. I still haven't messed with floats yet. As it turns out I have found several errors (or not supported features / design flaws) in DBP. Arrays only seem to be working properly when they are cast as anything smaller than integers, floats, or strings. For example dword and double integer type arrays give you wierd results. And the rnd command only works up to like 2147483647
value1 as double integer
value2 as dword
value3 as integer
value4 as word
value5 as byte
global temp1 as double integer
global temp2 as double integer
global temp3$ as string
global temp4 as integer
global temp5 as integer
global temp6 as byte
for numbs = 1 to 4
`set value to be converted
value1 = rnd((2147483647))-(2147483647/2)
value2 = rnd(2147483647)
value3 = rnd((2147483647))-(2147483647/2)
value4 = rnd(65535)
value5 = rnd(255)
`add value below integer range to string to get full string.
print "Double Integer"," ",value1," ",convert(value1)
print "DWord"," ",value2," ",convert(value2)
print "Integer"," ",value3," ",convert(value3)
print "Word"," ",value4," ",convert(value4)
print "byte"," ",value5," ",convert(value5)
next numbs
wait key
function convert(value as double integer)
`store value to be converted
temp1 = value
`set divider to remove all digits over integer range
temp2 = 1000000000000000000
`store maximum value of an integer
temp4 = 2147483647
`store when first number is found
temp6 = 0
`cycle through removing all digits after integer range and store in string
if temp1 <> 0
if value = -9223372036854775808 then temp1 = 0-value-1
if temp1 < 0 then temp1 = 0 - temp1
for i = 1 to 20
`search for first real digit
if temp6 = 0
temp5 = temp1/temp2
if temp3$ <> "" and temp5 <> 0
`temp3$ = str$(temp5)
temp6 = 1
temp3$ = ""
`when digit is found
else
temp3$ = str$(temp5)
endif
else
if temp1 < temp4
exit
endif
temp5 = temp1/temp2
temp3$ = temp3$ + str$(temp5)
temp1 = temp1-(temp5*temp2)
endif
temp2 = temp2/10
next i
endif
if value = -9223372036854775808
temp1 = temp1 + 1
endif
temp3$ = temp3$ + str$(temp1)
if value < 0 then temp3$ = "-"+temp3$
endfunction temp3$
[edit] And I don't know If you noticed yet but I hardly ever use UDT's as I had some bad experiences with them throwing errors.