Values are converted to the appropriate type before being written to a CDF file. For example, in the commands below, IDL converts the string "12" to a floating-point 12.0 before writing it:
varid=CDF_VARCREATE(fileid, 'VarName',['VARY','VARY'],$
CDF_VARPUT, fileid, 'VarName', '12' ; Reference by variable ID