Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.

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



Application Security Testing: An Integral Part of DevOps

The difference of FileLen() and Len()

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
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

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.



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