Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. my application taking to much time to get the job done

my application taking to much time to get the job done

Scheduled Pinned Locked Moved Visual Basic
databasehelptutorialcareer
8 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    eyes2007
    wrote on last edited by
    #1

    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

    D 1 Reply Last reply
    0
    • E eyes2007

      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

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      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

      E 1 Reply Last reply
      0
      • D Dave Kreskowiak

        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

        E Offline
        E Offline
        eyes2007
        wrote on last edited by
        #3

        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

        D 1 Reply Last reply
        0
        • E eyes2007

          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

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          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

          E 1 Reply Last reply
          0
          • D Dave Kreskowiak

            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

            E Offline
            E Offline
            eyes2007
            wrote on last edited by
            #5

            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)
            Next

            what else can i tell u just ask me thnx

            help everyone

            D 1 Reply Last reply
            0
            • E eyes2007

              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)
              Next

              what else can i tell u just ask me thnx

              help everyone

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              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

              E 1 Reply Last reply
              0
              • D Dave Kreskowiak

                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

                E Offline
                E Offline
                eyes2007
                wrote on last edited by
                #7

                what's that means (Good luck saving that back to an .xls file...) can u tell

                help everyone

                D 1 Reply Last reply
                0
                • E eyes2007

                  what's that means (Good luck saving that back to an .xls file...) can u tell

                  help everyone

                  D Offline
                  D Offline
                  Dave Kreskowiak
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups