|
-
Jun 24th, 2000, 04:39 PM
#1
Thread Starter
Member
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
-
Jun 24th, 2000, 04:55 PM
#2
Member
The FileLen function returns the number of bytes in a file, e.g.:
num = FileLen("c:\readme.txt")
-
Jun 24th, 2000, 05:01 PM
#3
Thread Starter
Member
how do i get the ascii value of a char?
-
Jun 24th, 2000, 07:37 PM
#4
Lively Member
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.
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."
To get the ascii value of a character, use the following code:
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 & ""
Hope this helps.
Later(z)
REM
"Innovate, don't immitate."
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|