Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Dec 5, 1997

The difference of FileLen() and Len()

Question:
What are the difference between FileLen() & Len()? When checking the file size making sure it is not exceeding 32KB in the text box, should I use FileLen() or Len()?

If I use FileLen(), is this code correct?

dim VarFile
dim FileType
FileType=commondialog1.filename
Open FileType for Input as #FreeFile
Do While NOT EOF(FreeFile)
Input #FreeFile, VarFile
if FileLen(FileType) > 32000 Then
Exit Do
End If
txtText.Text = txtText.Text + VarFile
Input #FreeFile, VarFile
Loop

Answer:
FileLen() returns the size of a disk file. Len() returns the size of a variable or constant:

   L = Len("hello")
   ' Returns 5, because "hello" 
   ' is five characters in length
To check whether a file is larger than 32K, you may use the FileLen() function before you open the file or the Lof() function after you open it. For more information, consult VB's documentation on the above functions.
DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date