This can be accomplished either by using the Jabaco Framework File handling.
Or you could do it "the Java way" as follows:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
Option Explicit
Import java#io#File
Import java#io#FileReader
Import java#io#FileWriter
Import java#io#LineNumberReader
Import java#io#PrintWriter
Public Sub Command1_Click()
Dim f As New File("myFile.txt")
Dim fw As New FileWriter(f)
Dim pw As New PrintWriter(fw)
pw.println "abc"
pw.println "123"
pw.println "aaaaaa"
pw.close
End Sub
Public Sub Command2_Click()
Dim f As New File("myFile.txt")
Dim fr As New FileReader(f)
Dim lnr As New LineNumberReader(fr)
Text1.text = lnr.readLine
Text2.text = lnr.readLine
Text3.text = lnr.readLine
lnr.close
End Sub
|
File handling has been discussed in
numerous posts. You might want to have a look at the
tutorial.
An example:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
|
Public Sub Command1_Click()
Dim myFile As VBFileHandler
' write
myFile = Open("C:\test.txt", Random, ReadAndWrite, Shared)
Call write(myFile, "testtesttest")
Call Close(myFile)
'read
myFile = Open("C:\test.txt", Random, ReadAndWrite, Shared)
MsgBox readline(myFile)
Call Close(myFile)
End Sub
|
My impression is that the Framework is not complete here.
But the Java constructs should work quite well.
For real applications, appropriate error handling would be necessary.
Greetings
A1880