02-25-2007 05:34 AM
02-26-2007 09:55 PM
02-28-2007 10:43 AM
03-01-2007 04:36 AM
03-02-2007 10:24 AM
03-04-2007 07:44 PM
In many cases, a VB6 app writes text files in a traditional BASIC way using OPEN/PRINT/INPUT/CLOSE functions. However, this approach is ASCII stream based, therefore you can't write a text partially into a specific line. (There is no method to control the offset in bytes or lines for PRINT/INPUT actions. ) To solve this, your app must buffer all the line contents before actual writing, then write all the lines at once.
For example, if your VB6 app wants to write a 1000 line text file, your app shall keep a string array such as
Dim astrLines(1 to 1000) As String
Then fill or replace each line as you want. When writing them into a text file, you can use traditional PRINT function repeating all the lines (1 to 1000) everytime you write.
Dim astrLines(1 To 1000) As String
Dim i As Long
...
astrLines(7) = "123456"
...
Open "C:\xxx\xxx.txt" For Output As #1
For i = 1 To 1000
Print astrLines(i)
Next i
Close #1
There are also other way to write/read specific part partially in a file -- Win32 standard API CreateFile/WriteFile/ReadFile/CloseHandle. However, it is not intended for text file, where each line length is different depending on the contents. These Win32 file API requires byte-offset and length info when you write/read partially.
03-12-2007 12:37 PM
03-12-2007 07:39 PM
It is a very basic syntax issue of VB6. In VB6, parentheses for enclosing the parameters can only be used under one of the 3 cases below:
1) invoke a FUNCTION and you explicitly receive its return
ex, r = MyFunc(x,y)
2) invoke a FUNCTION with CALL keyword without receiving its return
ex, Call MyFunc(x,y)
3) invoke a PROCEDURE with CALL keyword
ex, Call MyProc(x,y)
When you do not explicitly receive the FUNCTION return, or when you can not receive the return due to PROCEDURE (no return type), you only need one of the 2 ways below:
a) invoke a FUNCTION or PROCEDURE using CALL keyword and parentheses
ex, Call MyFunc(x,y), or Call MyProc(x,y)
b) invoke a FUNCTION or PROCEDURE without using parentheses
ex, MyFunc x,y, or MyProc x,y
03-13-2007 11:09 AM