public function checkmdi(byval formname as string ) as integer
  dim check as integer
  dim i as integer
  dim count as integer=me.mdichildren.length
  if count<1 then return -1
  for i=0 to count-1
    if mdichildren(i).name=formname then
       check=i
       exit for
    else
      check=-1
    end if
  next 
return check
end function