vba - File Export - Strange Characters -


i've been asked replicate file sent following excel vba code. problem export of data contained within "for" loop. quantity ".111" being written in export file "øsã=", ".222" being written "øsc>", , ".333" being written "ú~ª>".

i'm not entirely sure happening here. rate target legacy system have send our data able read data correctly (i.e. converted original values).

does have thoughts on going on , how replicate behaviour file can read?

type rigo_file status integer invio integer codice string * 13 quantita single udm integer end type  type type_file partita string * 10 macchina string * 25 articolo string * 25 colore string * 25 note string * 25 urgenza integer invio string * 3 righi(20) rigo_file end type  dim nropen integer dim nomefile string, nomefiletmp string dim rigo_file dim type_file dim typem type_file dim c integer  sub createfile() filedir = "c:\" filenamee = "testfile1.txt"  partita = right(cells(1, 3), 10) macchina = left(cells(2, 3), 25) articolo = left(cells(3, 3), 25) colore = left(cells(4, 3), 25) note = left(cells(5, 3), 25) urgenza = cdbl(cells(6, 3))  typem .partita = partita .macchina = macchina .articolo = articolo .colore = colore .note = note .urgenza = urgenza .invio = "001" ci = 1 20 .righi(ci).status = true .righi(ci).invio = 1 .righi(ci).codice = cells(8 + ci, 2) .righi(ci).quantita = cells(8 + ci, 3) .righi(ci).udm = 1 next ci end  nropen = freefile on error goto 0  open filedir & filenamee random access write shared #nropen len = len(typem)  put #nropen, 1, typem close #nropen 

end sub

put # writes data in kind of binary format - preceeding fields length bytes, converting numbers binary , other useful things. no problem long use get # read data in again. though file not strictly human readable.

if want write plain text ascii data, use print # or write # instead, , observe subtile differences between these 2 (delimiters, terminating cr+lf, etc.).

you may need specify each element of typem individually in print # or write # statement - not sure these 2 accept user defined objects.

but beware: target system ok read files created put # may refuse files created print # or write #


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -