Sunday, November 14, 2010

How to read dicom file from vb code?

I have to read dicom file in Vb. and dicom file is in binary format so . help me for that. how can i read this dicom file.



i am waiting for ans



thanks.How to read dicom file from vb code?
Take a look at:



vFileNumber = FreeFile

sFile = Space$(FileLen(FirstFile))

Open InFile For Binary Access Read As #vFileNumber

Get #vFileNumber, 1, sFile

Close #vFileNumber



The above code will read file any less than 64K in length into a single string sFile. If the file you want to read is longer than that you can read it in chunks of any size up to 64k by setting the length of sFile and leaving the second parameter (1) off of the get statement after the first read. Each consecutive read would overwrite the contents of sFile so you would need to handle that.



Here is what each of the five statements do.



1.Gets file number that is not in use

2.Sets the length of the receiving string to the file length (you may want or need to set it to something less than the file length).

3.Opens the file.

4.Reads the file getting as many characters as the length of sFile

5.Closes the file



Insert additional reeds as needed after the fourth step. You can tell when you have reached the end of the file by checking the length of the returned string.



Hope this helps.

No comments:

Post a Comment