|
-
Nov 7th, 2001, 08:33 AM
#1
Thread Starter
New Member
newbie xtreme
hey..nice site...
now I know this may be "basic" stuff but....
i wanna know if this code could be shortened or made more efficient? >>
Private Sub Form_Load()
Dim x As String
Open "artist.txt" For Append As #1
Open "song.txt" For Append As #2
Open "album.txt" For Append As #3
Open "genre.txt" For Append As #4
Close #1
Close #2
Close #3
Close #4
Open "artist.txt" For Input As #1
Do While Not EOF(1)
Input #1, x
lstArtist.AddItem x
Loop
Close #1
Open "song.txt" For Input As #1
Do While Not EOF(1)
Input #1, x
lstSong.AddItem x
Loop
Close #1
Open "album.txt" For Input As #1
Do While Not EOF(1)
Input #1, x
lstAlbum.AddItem x
Loop
Close #1
Open "genre.txt" For Input As #1
Do While Not EOF(1)
Input #1, x
lstGenre.AddItem x
Loop
Close #1
End Sub
thx! ;-)
-
Nov 7th, 2001, 08:39 AM
#2
-= B u g S l a y e r =-
VB Code:
Open "artist.txt" For Append As #1
Open "song.txt" For Append As #2
Open "album.txt" For Append As #3
Open "genre.txt" For Append As #4
Close #1
Close #2
Close #3
Close #4
?
-
Nov 7th, 2001, 08:43 AM
#3
well right off the top.. whats this for?
Open "artist.txt" For Append As #1
Open "song.txt" For Append As #2
Open "album.txt" For Append As #3
Open "genre.txt" For Append As #4
Close #1
Close #2
Close #3
Close #4
youre not doing anything here?
as for the rest...if the files arent to big..that code should be fine
you could grab the whole file then split it and add to the listbox...but stick with what you have for now.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 7th, 2001, 08:58 AM
#4
Originally posted by geoff_xrx
well right off the top.. whats this for?
Open "artist.txt" For Append As #1
Open "song.txt" For Append As #2
Open "album.txt" For Append As #3
Open "genre.txt" For Append As #4
Close #1
Close #2
Close #3
Close #4
I think it's just there to make sure the file exist before opening it For Input.
-
Nov 7th, 2001, 09:02 AM
#5
Hyperactive Member
If that's the case...
Use this function
Code:
Public Function FileExists(ByVal FileName As String) As Boolean
If Dir(FileName) = "" Then
FileExists = False
Else
FileExists = True
End If
End Function
Then you call it by going like this
Code:
if FileExists("C:\text.txt") then
msgbox "File exists"
else
msgbox "File does not exist"
end if
-
Nov 7th, 2001, 09:11 AM
#6
Joacim Andersson...
fine Mr."smartie who is actually 'awake' this early"
lol
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 7th, 2001, 09:16 AM
#7
Originally posted by geoff_xrx
Joacim Andersson...
fine Mr."smartie who is actually 'awake' this early"
lol
Well actually since I live in Sweden the time here is 3:15 PM so I should be awake.
-
Nov 7th, 2001, 09:19 AM
#8
See told you Im not awake...didnt even notice youre in Sweeden!
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 7th, 2001, 09:25 AM
#9
Originally posted by geoff_xrx
See told you Im not awake...didnt even notice youre in Sweeden!
Hmmm... well I'm awake and I notice that you're in Rochesteeer
-
Nov 7th, 2001, 09:39 AM
#10
Lively Member
I don't think you need the open for appends...
I thought "input" created files if they aren't there, just like "append"
---------------------------------------------------------
Calling someone an I.D.Ten.T. is MEAN!!!!!!!!
I.D.Ten.T.
ID10T
IDIOT
-
Nov 7th, 2001, 09:41 AM
#11
Originally posted by FRAIL_KNIGHT
I don't think you need the open for appends...
I thought "input" created files if they aren't there, just like "append"
No, opening a file for Append or Output creates the file if it doesn't exist but trying to open a non-existing file for Input raises an error.
-
Nov 7th, 2001, 10:13 AM
#12
Hyperactive Member
Well, I'm at work, I have to be awake.
Anyway. You don't need to create the files.
Check to see if it exists before creating it, and what the hell is there to input if it doesn't exist? Validity checking is the solution here, not wasting time making empty files and reading in nothing.
-
Nov 10th, 2001, 07:29 AM
#13
Thread Starter
New Member
Originally posted by Joacim Andersson
I think it's just there to make sure the file exist before opening it For Input.
thas is correct...
btw...wow!...thx for responses guyz... I just got a chance to come to the forum to see it....thx!
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
|