neophyte Posted July 29, 2009 Share Posted July 29, 2009 Hi Could you correct my code?!? 1- I need to open a file. 2-Check if the first number is the same of my variable. 3- yes, do..... 4 no, check the next line I search in this forum, I found a few thread about "freefile" http://www.cadtutor.net/forum/showthread.php?t=27744 But I didn't found the way to solve my problem. The variable strTexte still empty and the sub dont stop, it's "loop":huh: (I temporarily remove the "if" section) Sub FindScale(strVpScaleStd As String, strVpScaleCust As String) Dim strNomFichier As String Dim NomCalque As String Dim strTexte As String Dim iFichier As Integer Dim Position As Integer Dim strEchelle As String On Error Resume Next strNomFichier = "c:\vba\test.txt" iFichier = FreeFile Open strNomFichier For Input As #iFichier If Err Then MsgBox "Fichier " & strNomFichier & " introuvable." Exit Sub End If iFichier = FreeFile Do While Not EOF(iFichier) Line Input #iFichier, strTexte strTexte = Left(strTexte, 3) 'If Left(strTexte, 3) = strVpScaleStd Then ' Position = InStr(strTexte, "*") ' strEchelle = Mid$(strTexte, Position + 1) 'Else ' strTexte = "" 'End If Loop Close #iFichier If strEchelle = "" Then MsgBox "actual scale = " & strVpScaleCust End If End Sub Thanks Quote Link to comment Share on other sites More sharing options...
ollie Posted July 30, 2009 Share Posted July 30, 2009 Reference ms scription runtime dim fso as new filesystemobject dim fil as textstream set fil = fso.opentextstream while fil.eof == false wend EDIT: the actual method you are looking for is fil.OpenTextFile() that is only psuedo code but it should be enough to get you going Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.