Jump to content

Recommended Posts

Posted

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

Posted

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

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...