views:

21

answers:

1

I'm calling a Win32 API function and getting back a string padded with null characters. Trim$() doesn't remove them. Is there an easier solution then removing them one character at a time?

+1  A: 

if it's just padded to the right, you can use something like this:

function ntrim(byval theString as string) as string
  dim iPos as long
  iPos = instr(theString, chr$(0))
  if iPos > 0 then theString = left$(theString, iPos - 1)
end function
Don Dickinson
Thanks! I'd like to think I would have come up with that if I hadn't stayed up so late writing code...
BenV