scottmat
Messages postés438Date d'inscriptionsamedi 24 mai 2003StatutMembreDernière intervention23 janvier 2011
-
22 sept. 2005 à 23:06
cs_Willi
Messages postés2375Date d'inscriptionjeudi 12 juillet 2001StatutModérateurDernière intervention15 décembre 2018
-
23 sept. 2005 à 16:40
Bonsoir à tous :
Dim AllText, LineOfText As String
OpenDoc1.Filter = "Fichier text (*.txt)|*.TXT"
OpenDoc1.FileName = ""
OpenDoc1.ShowDialog()
If OpenDoc1.FileName <> "" Then
Try
FileOpen(1, OpenDoc1.FileName, OpenMode.Input)
Do Until EOF(1)
LineOfText = LineInput(1)
AllText = AllText & LineOfText & vbCrLf
Loop
RichTextBox2.Text = AllText
Catch
MsgBox("Erreur ! MyAppne peut ouvrir ce fichier")
Finally
FileClose(1)
End Try
End If
Jai une application, qui ouvre à laide dune boite de dialogue ouvrir, un fichier Texte (comme vous pouvez le voir plus haut), et laffiche dans un RichTextbox2. Le code marche a merveille, mais quand le fichier atteint + de 1Mo, mon pc commence a ramé alors que quand je l'ouvre avec Word il me louvre immédiatement !!!
Comment pourrais-je améliorer mon code pour avoir la même rapidité ou sinon mieux ?
crenaud76
Messages postés4172Date d'inscriptionmercredi 30 juillet 2003StatutMembreDernière intervention 9 juin 200628 23 sept. 2005 à 09:07
Avec un controle RichTextBox, c'est encore plus simple que cela ...
Tu as une méthode LoadFile() ...
OpenDoc1.Filter = "Fichier text (*.txt)|*.TXT"
OpenDoc1.FileName = ""
OpenDoc1.ShowDialog()
If OpenDoc1.FileName <> "" Then
Try
richtextbox1.LoadFile(OpenDoc1.FileName)
Catch
MsgBox("Erreur ! MyAppne peut ouvrir ce fichier")
Finally
FileClose(1)
End Try
End If