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:
Private Sub Command1_Click() k = 5 'temporary file length 'open "c:\usrtest.txt" for input as #1 '<<this line works when i swap it in :) Open strDataFileName For Input As #1 '<<this line won't when i select the same file :mad: ReDim Node(2, k) i = 0 Do While Not EOF(1) Input #1, lLat Input #1, lLon Input #1, bCon Node(0, i) = lLat Node(1, i) = lLon Node(2, i) = bCon i = i + 1 Loop Close #1 i = 0 Label3.Caption = Node(0, 0) & Node(1, 0) & Node(2, 0) For i = 0 To k Debug.Print Node(0, i); Node(1, i); Node(2, i) Next i End Sub Private Sub Command2_Click() Unload Me End Sub Private Sub Dir1_Change() File1.Path = Dir1.Path End Sub Private Sub Drive1_Change() Dir1.Path = Drive1.Drive End Sub Private Sub File1_Click() strDataFileName = File1.Path & File1.FileName ' <<selecting file here :wave: Label2.Caption = strDataFileName End Sub Private Sub Form_Load() Dim strDataFileName As String Dim lLat As Long, lLon As Long Dim bCon As Byte Drive1.Drive = "c:" End Sub Private Sub Text1_Change() If Right(Text1.Text, 4) = ".usr" Then strSaveFileName = Text1.Text Else strSaveFileName = Text1.Text & ".usr" End If Label1.Caption = strSaveFileName End Sub Private Sub Text2_Change() strTrailName = Text2.Text Label2.Caption = strTrailName End Sub




Reply With Quote