Jump to content

File size: Difference between revisions

→‎=={{header|Visual Basic}}==: added Visual Basic example
(→‎=={{header|Visual Basic}}==: added Visual Basic example)
Line 1,432:
<lang vedit>Num_Type(File_Size("input.txt"))
Num_Type(File_Size("/input.txt"))</lang>
 
=={{header|Visual Basic}}==
{{works with|Visual Basic|6}}
<lang vb>Option Explicit
 
----
 
Sub DisplayFileSize(ByVal Path As String, ByVal Filename As String)
Dim i As Long
If InStr(Len(Path), Path, "\") = 0 Then
Path = Path & "\"
End If
On Error Resume Next 'otherwise runtime error if file does not exist
i = FileLen(Path & Filename)
If Err.Number = 0 Then
Debug.Print "file size: " & CStr(i) & " Bytes"
Else
Debug.Print "error: " & Err.Description
End If
End Sub
 
----
 
Sub Main()
DisplayFileSize CurDir(), "input.txt"
DisplayFileSize CurDir(), "innputt.txt"
DisplayFileSize Environ$("SystemRoot"), "input.txt"
End Sub
</lang>
{{out}}
<pre>file size: 37 Bytes
error: file not found
file size: 37 Bytes</pre>
 
=={{header|Visual Basic .NET}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.