[Resolved]connect Progress Bar to function
i finally after the help from friends here finished writing the code to my programe.....
so now i want to add Progress Bar to my function that while the function process the files the Progress Bar count....
here is part of code
Code:
Private Sub Command2_Click()
Dim sAfter As String
Dim sBefore As String
Dim i As Long
FirText = " " & FirText & " "
FirText = Replace(FirText, vbCr, " " & vbCr) & " "
FinText = Left(FirText, 1)
For i = 2 To Len(FirText) - 1
sAfter = Mid(FirText, i + 1, 1)
sBefore = Mid(FirText, i - 1, 1)
Select Case Mid(FirText, i, 1)
Case "("
FinText = FinText & "["
Case ")"
FinText = FinText & "]"
Case "["
FinText = FinText & "{"
Case "]"
FinText = FinText & "}"
Case "{"
FinText = FinText & "{"
Case "}"
FinText = FinText & "}"
Case "-"
FinText = FinText & "-"
Case "+"
FinText = FinText & "+"
Case "="
FinText = FinText & "="
Case "0"
FinText = FinText & "*"
Case "%"
FinText = FinText & "$"
Case "Ç"
Select Case sBefore
Case "È", "Ê", "Ë", "Ì", "Í", "Î", "Ú", "ä", "å", "í"
FinText = FinText & "D"
Case "á"
FinText = FinText & ""
Case Else
FinText = FinText & "C"
End Select
Case Else
If Mid(FirText, i, 2) = vbNewLine Then
FinText = FinText & vbNewLine
i = i + 1
End If
End Select
Next
FinText = FinText & Right$(FirText, 1)
FinText = Trim(FinText)
End sub
some letters not clear because this programe to deal with arabic language....
now my question is how can i connect Progress Bar to this function which take text files and process them i try many times (some times the process finshed while the Progress Bar fill just 3 or 4 unit and times Progress Bar finshed count while the function not finshed process the text.......
how i can do that in the corect way....
i hope you understand the idea;)
and sorry for my english:blush:
Re: connect Progress Bar to function
Put a progressbar on your form.
Code:
'the beginning of your code
FinText = Left(FirText, 1)
ProgressBar1.Min = 0
ProgressBar1.Max = Len(FirText) - 1
For i = 2 To Len(FirText) - 1
ProgressBar1.Value = i
sAfter = Mid(FirText, i + 1, 1)
'the rest of your code
Re: connect Progress Bar to function
Quote:
Originally Posted by Al42
Put a progressbar on your form.
Code:
'the beginning of your code
FinText = Left(FirText, 1)
ProgressBar1.Min = 0
ProgressBar1.Max = Len(FirText) - 1
For i = 2 To Len(FirText) - 1
ProgressBar1.Value = i
sAfter = Mid(FirText, i + 1, 1)
'the rest of your code
thx man it is work 100% but with one problem it is make a big slow in the process ( it was take for example 30 sec to process file conatins 50000 lines now it take about 100 sec to do that)
Re: connect Progress Bar to function
Change
ProgressBar1.Value = i
to
If i Mod 100 = 0 Then ProgressBar1.Value = i
Re: connect Progress Bar to function
Quote:
Originally Posted by Ellis Dee
Change
ProgressBar1.Value = i
to
If i Mod 100 = 0 Then ProgressBar1.Value = i
perfect:thumb:
a big thx man to you and to Al42:wave:
Re: [Resolved]connect Progress Bar to function
If you want to make the code faster still, comment out these two lines:
Code:
sAfter = Mid(FirText, i + 1, 1)
sBefore = Mid(FirText, i - 1, 1)
..and change this:
Code:
Select Case sBefore
to:
Code:
Select Case Mid$(FirText, i - 1, 1)
You should also change all other "Mid" to "Mid$", as the $ version is faster.