Results 1 to 8 of 8

Thread: Resolved: having trouble opening a file

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2005
    Posts
    47

    Resolved Resolved: having trouble opening a file

    i am having trouble opening a file when the file name is selected through a file list box, the file will open and run just fine when i simply type in the location in the code. any ideas what might be wrong? or perhaps a simpler way to select a file to open.

    i know its probably simple, but being a beginner i sometimes can't see the easy ones.

    thanks
    jerry

    VB Code:
    1. Private Sub Command1_Click()
    2.  
    3.  
    4. k = 5 'temporary file length
    5. 'open "c:\usrtest.txt" for input as #1  '<<this line works when i swap it in :)
    6. Open strDataFileName For Input As #1    '<<this line won't when i select the same file :mad:
    7.    ReDim Node(2, k)
    8.    i = 0
    9.    Do While Not EOF(1)
    10.         Input #1, lLat
    11.         Input #1, lLon
    12.         Input #1, bCon
    13.        
    14.         Node(0, i) = lLat
    15.         Node(1, i) = lLon
    16.         Node(2, i) = bCon
    17.        
    18.        
    19.         i = i + 1
    20.        
    21.     Loop
    22.     Close #1
    23.      i = 0
    24.      
    25.     Label3.Caption = Node(0, 0) & Node(1, 0) & Node(2, 0)
    26.     For i = 0 To k
    27.         Debug.Print Node(0, i); Node(1, i); Node(2, i)
    28.     Next i
    29.    
    30. End Sub
    31.  
    32. Private Sub Command2_Click()
    33. Unload Me
    34.  
    35. End Sub
    36.  
    37. Private Sub Dir1_Change()
    38. File1.Path = Dir1.Path
    39.  
    40. End Sub
    41.  
    42. Private Sub Drive1_Change()
    43. Dir1.Path = Drive1.Drive
    44.  
    45. End Sub
    46.  
    47. Private Sub File1_Click()
    48. strDataFileName = File1.Path & File1.FileName  ' <<selecting file here :wave:
    49.  
    50. Label2.Caption = strDataFileName
    51.  
    52. End Sub
    53.  
    54. Private Sub Form_Load()
    55. Dim strDataFileName As String
    56. Dim lLat As Long, lLon As Long
    57. Dim bCon As Byte
    58.  
    59.  
    60. Drive1.Drive = "c:"
    61.  
    62.  
    63. End Sub
    64.  
    65. Private Sub Text1_Change()
    66. If Right(Text1.Text, 4) = ".usr" Then
    67.         strSaveFileName = Text1.Text
    68.         Else
    69.         strSaveFileName = Text1.Text & ".usr"
    70.         End If
    71. Label1.Caption = strSaveFileName
    72.        
    73.  
    74. End Sub
    75.  
    76. Private Sub Text2_Change()
    77. strTrailName = Text2.Text
    78. Label2.Caption = strTrailName
    79.  
    80. End Sub
    Last edited by jerrybark; Aug 18th, 2005 at 09:15 PM. Reason: Resolved

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width