my application taking to much time to get the job done
-
hi all i m working on a project that's simply open a txt, csv, xls file, make some modifications and save the file in the same format i m facing two problems 1. how to save the file in xls format ( i have opened it but unable to save ) 2. how to decrease the time taken by the application to process my query ( my query is to search some thing in the text.) because the text file contains more than 1,00,00,000 lines, when i search the string in that file the execution of program decrease drastically. i m using rich text box the code i used to search is For j As Integer = 0 To str1.Length - 1 K = 0 For i As Integer = 0 To len If K <= len Then If (rtb1.Find(str1(j), K, RichTextBoxFinds.MatchCase)) <> -1 Then rtb1.Select(rtb1.Find(str1(j), K, RichTextBoxFinds.MatchCase), str1(j).Length) rtb1.SelectionBackColor = Color.Yellow 'rtb1.SelectedText = "zz " End If End If 'lbl2.Text = K & " " & j K = K + str1(j).Length pg1.Value += 1 Application.DoEvents() Next Next does some one has any idea thnx in advance
help everyone
-
hi all i m working on a project that's simply open a txt, csv, xls file, make some modifications and save the file in the same format i m facing two problems 1. how to save the file in xls format ( i have opened it but unable to save ) 2. how to decrease the time taken by the application to process my query ( my query is to search some thing in the text.) because the text file contains more than 1,00,00,000 lines, when i search the string in that file the execution of program decrease drastically. i m using rich text box the code i used to search is For j As Integer = 0 To str1.Length - 1 K = 0 For i As Integer = 0 To len If K <= len Then If (rtb1.Find(str1(j), K, RichTextBoxFinds.MatchCase)) <> -1 Then rtb1.Select(rtb1.Find(str1(j), K, RichTextBoxFinds.MatchCase), str1(j).Length) rtb1.SelectionBackColor = Color.Yellow 'rtb1.SelectedText = "zz " End If End If 'lbl2.Text = K & " " & j K = K + str1(j).Length pg1.Value += 1 Application.DoEvents() Next Next does some one has any idea thnx in advance
help everyone
eyes2007 wrote:
1. how to save the file in xls format ( i have opened it but unable to save )
What code are you using to load this file?
eyes2007 wrote:
. how to decrease the time taken by the application to process my query ( my query is to search some thing in the text.) because the text file contains more than 1,00,00,000 lines, when i search the string in that file the execution of program decrease drastically.
Uhhh...How many lines again?? I can't tell if that's a billion, million, or 10 million... What did you expect?? That's an enormous amount of text to search through. You're not going to get instant results. Why are you using a RichTextBox to search through a text file?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
eyes2007 wrote:
1. how to save the file in xls format ( i have opened it but unable to save )
What code are you using to load this file?
eyes2007 wrote:
. how to decrease the time taken by the application to process my query ( my query is to search some thing in the text.) because the text file contains more than 1,00,00,000 lines, when i search the string in that file the execution of program decrease drastically.
Uhhh...How many lines again?? I can't tell if that's a billion, million, or 10 million... What did you expect?? That's an enormous amount of text to search through. You're not going to get instant results. Why are you using a RichTextBox to search through a text file?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
i use openfiledialog to load the file. rtb1.LoadFile(objFileOpen.FileName, RichTextBoxStreamType.PlainText) can u suggest me one better tool to use then rich text box (it is notepad like application i m working on) thnx
help everyone
eyes2007 wrote:
i use openfiledialog to load the file. rtb1.LoadFile(objFileOpen.FileName, RichTextBoxStreamType.PlainText)
You're using this code to load an Excel (*.xls) file into an RTB?? :confused: Why are you using a RichTextBox at all?? If you're coding is just doing search and replace of text in a file, why are you using a RTB?? I don't know what the point of this code is. First, you say you're doing search and replace in several types of files containing millions of lines of text. Then you say you're writing a Notepad replacement. Which is it?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
eyes2007 wrote:
i use openfiledialog to load the file. rtb1.LoadFile(objFileOpen.FileName, RichTextBoxStreamType.PlainText)
You're using this code to load an Excel (*.xls) file into an RTB?? :confused: Why are you using a RichTextBox at all?? If you're coding is just doing search and replace of text in a file, why are you using a RTB?? I don't know what the point of this code is. First, you say you're doing search and replace in several types of files containing millions of lines of text. Then you say you're writing a Notepad replacement. Which is it?
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007hi dave i think u r not understand my problem, i will explain in detail 1. my application's initial requirement is to open files having extention of *.txt, *.xls, *.csv 2. i need an editor to edit data of the files ( I already made it using rich text box, that's y i use RTB ( will u suggest a better option to use to edit text of data )) 3. the code to open excel file is
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
For j As Integer = 0 To ds.Tables(0).Columns.Count - 1
rtb1.Text = rtb1.Text & " " & ds.Tables(0).Rows(i).Item(j).ToString()
Next
rtb1.Text = rtb1.Text & Chr(13)
Nextwhat else can i tell u just ask me thnx
help everyone
-
hi dave i think u r not understand my problem, i will explain in detail 1. my application's initial requirement is to open files having extention of *.txt, *.xls, *.csv 2. i need an editor to edit data of the files ( I already made it using rich text box, that's y i use RTB ( will u suggest a better option to use to edit text of data )) 3. the code to open excel file is
For i As Integer = 0 To ds.Tables(0).Rows.Count - 1
For j As Integer = 0 To ds.Tables(0).Columns.Count - 1
rtb1.Text = rtb1.Text & " " & ds.Tables(0).Rows(i).Item(j).ToString()
Next
rtb1.Text = rtb1.Text & Chr(13)
Nextwhat else can i tell u just ask me thnx
help everyone
eyes2007 wrote:
3. the code to open excel file is For i As Integer = 0 To ds.Tables(0).Rows.Count - 1 For j As Integer = 0 To ds.Tables(0).Columns.Count - 1 rtb1.Text = rtb1.Text & " " & ds.Tables(0).Rows(i).Item(j).ToString() Next rtb1.Text = rtb1.Text & Chr(13) Next
Good luck saving that back to an .xls file... You can use either a RTB or a TextBox with the character limit set to -1. You can't improve the performance of the search and replace on huge files. You simply have to pare down the size of the file.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
eyes2007 wrote:
3. the code to open excel file is For i As Integer = 0 To ds.Tables(0).Rows.Count - 1 For j As Integer = 0 To ds.Tables(0).Columns.Count - 1 rtb1.Text = rtb1.Text & " " & ds.Tables(0).Rows(i).Item(j).ToString() Next rtb1.Text = rtb1.Text & Chr(13) Next
Good luck saving that back to an .xls file... You can use either a RTB or a TextBox with the character limit set to -1. You can't improve the performance of the search and replace on huge files. You simply have to pare down the size of the file.
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007 -
what's that means (Good luck saving that back to an .xls file...) can u tell
help everyone
It means you created a string of text out of the data in each cell. Sure, you can make changes to the text, but how are you going to save those changes back to an .XLS file??
A guide to posting questions on CodeProject[^]
Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
2006, 2007