|
-
Oct 28th, 2009, 02:37 AM
#1
Thread Starter
Junior Member
Freezing up
The script searches for strings inside of another string.
My problem is that List3 loads +400 items and then when it searches it will freeze up the program.
I put a limit on it to only load 20 items so it dose not freeze up.
But it dose not get close to finishing what it needs to do. 
Code:
Private Sub Command1_Click()
Const StringLen = 20
Dim MyArr(StringLen), TxtString As String
List3.Clear
List4.Clear
Randomize
' Generate random string and list of numbers
For i = 1 To StringLen
TxtString = Text1.Text
Call loadlist
Next
' Search List
For i = 1 To StringLen
If InStr(TxtString, List3.List(i - 1)) Then
List5.AddItem List3.List(i - 1) & " found!"
Else: List4.AddItem List3.List(i - 1) & " not found."
End If
Next
End Sub
'Populates the listbox
Private Sub loadlist()
Dim strTemp As String
Open App.Path & "\Item2.txt" For Input As #1
Do Until EOF(1) = True
Line Input #1, strTemp
List3.AddItem strTemp
Loop
Close #1
End Sub
-
Oct 28th, 2009, 06:29 AM
#2
Re: Freezing up
Private Sub Command1_Click()
Const StringLen = 20
Dim MyArr(StringLen), TxtString As String
List3.Clear
List4.Clear
Randomize
' Generate random string and list of numbers
For i = 1 To StringLen
TxtString = Text1.Text
Call loadlist
Next
' Search List
For i = 1 To StringLen
If InStr(TxtString, List3.List(i - 1)) Then
List5.AddItem List3.List(i - 1) & " found!"
Else: List4.AddItem List3.List(i - 1) & " not found."
End If
Next
End Sub
'Populates the listbox
Private Sub loadlist()
Dim strTemp As String
Open App.Path & "\Item2.txt" For Input As #1
Do Until EOF(1) = True
Line Input #1, strTemp
List3.AddItem strTemp
Loop
Close #1
End Sub
I didn't understand what your code is doing here... 
> Why are you using ?
>
For i = 1 To StringLen
TxtString = Text1.Text
Call loadlist
Next
Why are you assigning TxtString inside the loop??
> Why are you loading data from the file using loadlist inside a loop???
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
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
|