|
-
Oct 3rd, 2010, 06:46 PM
#1
Thread Starter
Fanatic Member
Need help with several things about text files
Okay. lets say in a text file, i have:
10/10/10, 11/12/13, 10/20/21,
all on one line. how can i get it to do the following:
1)Seperate each date and put it into a listbox
2)Seperate each date and put it into a variable
I am stuck... Please help. Also, is there a way in vb6 to export several listboxes to a spreadsheet file? if so, how? Thanks!
-
Oct 3rd, 2010, 07:34 PM
#2
Re: Need help with several things about text files
Try this:
vb Code:
Private Sub Command1_Click() Dim str As String Dim i As Integer Dim entry As String ff = FreeFile Open App.Path & "\test.txt" For Input As #ff For i = 0 To Len(ff) + 1 Input #ff, entry List1.AddItem entry str = entry Next i MsgBox (str) Close #ff End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 3rd, 2010, 07:39 PM
#3
Thread Starter
Fanatic Member
Re: Need help with several things about text files
o.o What the heck... Okay. I want multiple entries... Not just one.. Like if i had multiple dates... And on top of that, have no idea what that codes does... Well.. Have some idea. What does the Len(ff) do?
-
Oct 3rd, 2010, 07:59 PM
#4
Re: Need help with several things about text files
 Originally Posted by Gamemaster1494
o.o What the heck... Okay. I want multiple entries... Not just one.. Like if i had multiple dates... And on top of that, have no idea what that codes does... Well.. Have some idea. What does the Len(ff) do?
Have you tested the code? It works with multiple entries! The len(ff) is the maximum number of entries in the file.
Edit:
To change the number of entries that appear, change the 1 to a different number. Say you have 30 entries in the file change the number "1" to "29". This value is the iteration value for the for cycle meaning how many times do you want it to run.
Last edited by Nightwalker83; Oct 3rd, 2010 at 08:24 PM.
Reason: Adding more!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 3rd, 2010, 08:39 PM
#5
Thread Starter
Fanatic Member
Re: Need help with several things about text files
Yeah. it works... now how can i make it do that at certain entries? Like if the txt file had:
Jacob
Pouring
Noway
10/10/10, 10/11/10, 10/12/10,
OkayIGetIt
Only have it to do it at line 4? and do something else for the others?
-
Oct 3rd, 2010, 09:02 PM
#6
Re: Need help with several things about text files
You could add this code just before the next.
vb Code:
If i = 4 Then List1.AddItem entry str = entry End If
Last edited by Nightwalker83; Oct 3rd, 2010 at 09:12 PM.
Reason: Fixed spelling!
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 3rd, 2010, 09:06 PM
#7
Thread Starter
Fanatic Member
Re: Need help with several things about text files
Okay. So what code is it that separates it?
-
Oct 3rd, 2010, 09:15 PM
#8
Re: Need help with several things about text files
The conditional statement checks to see which value of entry you you want to add to the list box and if the value matches it adds it to the list box.
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
-
Oct 3rd, 2010, 09:45 PM
#9
Thread Starter
Fanatic Member
Re: Need help with several things about text files
um... okay.... Hmmm.... So... How would i get it to where like the txt file says:
10/10/10, 21/10/10, 21/11/10
for example. and i want
variable(1) = 10/10/10, variable(2) = 21/10/10, variable(3) = 21/11/10
Is there a way to do that?
-
Oct 3rd, 2010, 10:41 PM
#10
Re: Need help with several things about text files
Try this:
vb Code:
Private Sub Command1_Click() Dim x As Integer Dim sInputArr() As String Dim i As Integer Dim a As Integer Dim entry As String ff = FreeFile Open App.Path & "\test.txt" For Input As #ff For i = 0 To Len(ff) + 5 Input #ff, entry If i = 3 Or i = 4 Or i = 5 Then List1.AddItem entry 'Split up the String into the Array If InStr(entry, ",") Then 'More than 1 word, so split sInputArr = Split(entry, ",") Else ReDim sInputArr(i) 'Only 1 word, so place it in the Array sInputArr(i) = entry MsgBox (sInputArr(i)) End If End If Next i Close #ff End Sub
when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
https://get.cryptobrowser.site/30/4111672
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
|