|
-
Oct 19th, 2000, 08:55 PM
#1
Thread Starter
Lively Member
thanks a lot...
secodly what if i have two list boxes one with strings and the other with integers:
lstname lstAge
Sally 12
Moe 26
Shanel 23
Hary 24
how do add both to a file??
so the text file looks like this
Sally, 12
Moe, 26
Shanel, 23
Hary, 24
please help?!!1
-
Oct 19th, 2000, 10:34 PM
#2
You can use the Replace function to do this.
Code:
Private Sub Form_Load()
Dim x(3) As String
x(0) = "Sally 12"
x(1) = "Moe 26"
x(2) = "Shanel 23"
x(3) = "Hary 24"
For i = LBound(x) To UBound(x)
List1.AddItem x(i)
Next i
End Sub
Private Sub Command1_Click()
For i = 0 To List1.ListCount - 1
strTxt = Replace(List1.List(i), " ", Chr(44) & Chr(32))
List2.AddItem strTxt
Next i
End Sub
-
Oct 19th, 2000, 10:35 PM
#3
Fanatic Member
Code:
Dim text As String
text = lstname.Text & "," & lstage.Text & vbCrLf
Open "C:\myfile.txt" For OutPut As #1
Print #1, text
Close #1
Hope that helps,
D!m
-
Oct 19th, 2000, 10:38 PM
#4
Assuming that the 2 listboxes are in synch with each other (i.e., they both have the same number of items and that the first item of the first box is associated with the first item of the second box, the second item of the first box is associated with the second item of the second box, etc.) you could use the following:
Code:
Dim intX As Integer
Dim intFileNbr As Integer
intFileNbr = FreeFile
Open "C:\Whatever\MyFile.Dat" For Output As #intFileNbr
For intX = 0 to lstName.ListCount - 1
Write #intFileNbr, lstName.List(intX), Val(lstAge.List(intX))
Next
"It's cold gin time again ..."
Check out my website here.
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
|