how do i put the number of bytes a file consists into an integer?
and how do i put a value of a char or the value of all of the bytes in a file into an integer?
thanks
Printable View
how do i put the number of bytes a file consists into an integer?
and how do i put a value of a char or the value of all of the bytes in a file into an integer?
thanks
The FileLen function returns the number of bytes in a file, e.g.:
num = FileLen("c:\readme.txt")
how do i get the ascii value of a char?
Right then. To get the length of a file in bytes, you can use the LEN function. It is probably better for you to use a Long data type than an integer. It depends on the size of the file you want to know the size of. For example, if you were dealing with an .exe or an mp3, you would probably use a long, as it's length would probably exceed the integers range. Always go for the long if you're not sure.
To get the ascii value of a character, use the following code:Code:'Get the length of a file in bytes.
Dim lngData As Long
Open "C:\MyFile.txt" For Binary As #1
lngData = LOF(1)
Close #1
MsgBox " The length of the file is: " & lngData & " bytes."
Hope this helps.Code:'Get the asci code for a character.
Dim strChar As String * 1 '1 character long.
Dim intAsc As Integer
strChar = "R"
intAsc = Asc(strChar)
MsgBox "The Asc number for the character 'R' is " & intAsc & ""
Later(z)
REM