|
-
Jul 17th, 2007, 12:42 PM
#1
Thread Starter
Member
[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
Last edited by king4ever101; Jul 17th, 2007 at 02:22 PM.
-
Jul 17th, 2007, 01:22 PM
#2
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
The most difficult part of developing a program is understanding the problem.
The second most difficult part is deciding how you're going to solve the problem.
Actually writing the program (translating your solution into some computer language) is the easiest part.
Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.
Please Help Us To Save Ana
-
Jul 17th, 2007, 01:42 PM
#3
Thread Starter
Member
Re: connect Progress Bar to function
 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)
-
Jul 17th, 2007, 02:18 PM
#4
Re: connect Progress Bar to function
Change
ProgressBar1.Value = i
to
If i Mod 100 = 0 Then ProgressBar1.Value = i
-
Jul 17th, 2007, 02:21 PM
#5
Thread Starter
Member
Re: connect Progress Bar to function
 Originally Posted by Ellis Dee
Change
ProgressBar1.Value = i
to
If i Mod 100 = 0 Then ProgressBar1.Value = i
perfect
a big thx man to you and to Al42
-
Jul 17th, 2007, 02:51 PM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|