|
-
Nov 15th, 2000, 10:02 AM
#1
Thread Starter
Lively Member
This will sound really stupid but I have forgotten the syntax for this stuff.... I am trying to open a file, actually its a log file from vb6 and input some lines. I am cool with most of it but don't know how to write to it.... I am using the following: Open strfilename for append as #2
I then need to add some lines of text. Any ideas? Also I need to know how to take the contents of list box and variablize all of it so that it can be included in the log file. Ideas?
-
Nov 15th, 2000, 10:13 AM
#2
Fanatic Member
Check out WRITE, PUT, PRINT etc.,
With the list box, simply loop through the list box, and add the entries to a text array, then you can use
e.g.
Code:
Dim MyListArray() As String
ReDim MyListArray(MyList.ListCount - 1)
For id = 0 To MyList.ListCount - 1
MyListArray[id] = MyList.List(id)
Next id
For id=0 to UBound(MyListArray)
WRITE #1, MyListArray[id]
Next id
OK?
Paul.
Not nearly so tired now...
Haven't been around much so be gentle...
-
Nov 15th, 2000, 10:55 AM
#3
_______
<?>
You can write directly from the list as well.
Code:
'sample code / List1 / Command1 / File "C:\my Documents\myfile.txt"
Option Explicit
Private Sub Command1_Click()
Dim myString As String
myString = "Help me out here will you" & vbCrLf
myString = myString & "OK, here we go" & vbCrLf
myString = myString & "Let's add to log."
Dim myFile As String
myFile = "C:\My Documents\myfile.txt"
Dim intnum As Integer, myCount As Integer
intnum = FreeFile
Open myFile For Append As intnum
'add your text string
Print #intnum, myString
'add your list text
For myCount = 0 To List1.ListCount - 1
List1.ListIndex = myCount
Print #intnum, List1.Text
Next myCount
Close #intnum
'reset index pointer of list1
List1.ListIndex = 0
End Sub
Private Sub Form_Load()
'fill list1 with something
Dim i As Integer
For i = 1 To 10
List1.AddItem i
Next i
End Sub
[Edited by HeSaidJoe on 11-15-2000 at 11:08 AM]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 15th, 2000, 11:21 AM
#4
Fanatic Member
Damn, didn't think of that!
P.
Not nearly so tired now...
Haven't been around much so be gentle...
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
|