Originariamente inviato da Lukather
Ciao a tutti,
ho un codice di questo tipo per aprire un file esterno txt:
codice:
If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            myStream = openFileDialog1.OpenFile()
            MsgBox(myStream.Length)
            If Not (myStream Is Nothing) Then
                Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(openFileDialog1.FileName)
                    MyReader.TextFieldType = FileIO.FieldType.Delimited
                    MyReader.SetDelimiters(" ")
                    Dim currentRow As String()
                    While Not MyReader.EndOfData
                        currentRow = MyReader.ReadFields()
                        Dim currentField As String
                        For Each currentField In currentRow
'codice
                        Next
                        myStream.Close()
                    End While
                End Using
            End If
End if
Aprendo file txt grossi (ma lo fa già con file da 54Kb) si freeza tutto mentre carica in memoria...a parte che non capisco la lentezza nell'aprire un file da 60Kb, come posso visualizzare una progressbar mentre importa il suddetto file?

Grazie, Lorenzo
keggendo il codice è vb.net e non vb6 cmq ad ogni modo
crei un controllo progressbar chiamiamolo pBar.
poi fai
codice:
pBar.minimum = 0 
pBar.maximum = myStream.Length
diventa così:
codice:
If openFileDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
pBar.minimum = 0 

            myStream = openFileDialog1.OpenFile()
            'MsgBox(myStream.Length)
            If Not (myStream Is Nothing) Then
                MsgBox(myStream.Length) ' meglio qui, nel caso myStream fosse nullo(nothing) ti darebbe errore
                pBar.maximum = myStream.Length
                Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(openFileDialog1.FileName)
                    MyReader.TextFieldType = FileIO.FieldType.Delimited
                    MyReader.SetDelimiters(" ")
                    Dim currentRow As String()
                    While Not MyReader.EndOfData
                        currentRow = MyReader.ReadFields()
                        Dim currentField As String
                        For Each currentField In currentRow
'codice
                         
                        Next
                        myStream.Close()
                        pBar.Increment(1)
                    End While
                End Using
            End If
End if