|
-
Feb 20th, 2003, 06:06 PM
#1
Thread Starter
Addicted Member
Best Load Code - Lol
Ok well im just curious about the load code now and this is what I use at the time:
VB Code:
On Error GoTo 1
With CD1
.DialogTitle = "Open User File"
.Filter = "All Supported Types|*.usr;*.txt;*.dat|"
.ShowOpen
Dim sText As String
Dim x As Integer
x = FreeFile
On Error Resume Next
Open .FileName For Input As #x
While Not EOF(x)
Input #x, sText$
If sText$ = "" Then
Exit Sub
Else
List1.AddItem sText$
DoEvents
End If
Wend
Close #x
End With
Exit Sub
1
Exit Sub
Im just looking for advice on what the best load code is and if anything here could be changed to make it better? Thanks guys I appreciate your help
Thanks For The Help Guys 
-
Feb 20th, 2003, 06:13 PM
#2
Let me in ..
What is this, some god damn game ? 
Its fine.
-
Feb 20th, 2003, 06:22 PM
#3
Thread Starter
Addicted Member
Well no im just using a lot of save and load functions and some people have said its not the ebst code to use so I wanted to ask to see if it was the best so thanks for your help man
Thanks For The Help Guys 
-
Feb 20th, 2003, 06:29 PM
#4
The picture isn't missing
if you want best, try leaning toward building your own OS, then you will have much more direct access to the drive.
really, it's fine
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Feb 20th, 2003, 06:47 PM
#5
Let me in ..
Re: Best Load Code - Lol
Originally posted by _Vb_N00bie_
Ok well im just curious about the load code now and this is what I use at the time:
VB Code:
On Error GoTo 1
With CD1
.DialogTitle = "Open User File"
.Filter = "All Supported Types|*.usr;*.txt;*.dat|"
.ShowOpen
Dim sText As String
Dim x As Integer
x = FreeFile
On Error Resume Next
Open .FileName For Input As #x
While Not EOF(x)
Input #x, sText$
If sText$ = "" Then
Exit Sub
Else
List1.AddItem sText$
DoEvents
End If
Wend
Close #x
End With
Exit Sub
1
Exit Sub
Im just looking for advice on what the best load code is and if anything here could be changed to make it better? Thanks guys I appreciate your help
Hang on, there is a problem in this code.
VB Code:
While Not EOF(x)
Input #x, sText$
If sText$ = "" Then
Exit Sub
Else
List1.AddItem sText$
DoEvents
End If
Wend
If sText$ = "" Then
Exit Sub
Else
if text is blank you are exitting the sub. Well, what if there is some blank line in between and there is text after that.
I mean, lets say text file contains ..
1
2
3
5
7
4
4
4
77
as soon as it will detect the blank after 3, it will exit the sub. While there is data after that. Isn't it ?
You should rather say ..
VB Code:
While Not EOF(x)
Input #x, sText$
If trim(sText$) <> "" Then
List1.AddItem sText$
End If
DoEvents
Wend
-
Feb 20th, 2003, 08:10 PM
#6
More standard formatting.
VB Code:
Dim sText As String
Dim x As Integer
On Error GoTo ErrorExit
With CD1
.DialogTitle = "Open User File"
.Filter = "All Supported Types|*.usr;*.txt;*.dat|"
.ShowOpen
x = FreeFile
On Error Resume Next
Open .FileName For Input As #x
While Not EOF(x)
Input #x, sText$
If sText$ = "" Then
Exit Sub
Else
List1.AddItem sText$
DoEvents
End If
Wend
Close #x
End With
Exit Sub
ErrorExit:
Exit Sub
End Sub
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
|