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. How to collect the same data?

How to collect the same data?

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
5 Posts 3 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.
  • P Offline
    P Offline
    phowarso
    wrote on last edited by
    #1

    I have a table's field that "Date". It contains severial data, some are same. (Eg. 20/11/07 20/11/07 20/11/07 25/12/07 25/12/07 25/12/07 27/12/07 27/12/07 29/12/07 29/12/07 30/12/07 31/12/07 ,etc...) 20/11/07 is 3 data. 25/12/07 is 3 data. 27/12/07 is 2 data. 29/12/07 is 2 data. 30/12/07 is only one data. 31/12/07 is only one data. I wanna display the above data onto a ComboBox by desending. I wanna collect only one data for a same many data. (Eg. 31/12/07 30/12/07 29/12/07 27/12/07 25/12/07 20/11/07 ... etc ) Please give me some suggestion for above metter.:confused:

    C R 2 Replies Last reply
    0
    • P phowarso

      I have a table's field that "Date". It contains severial data, some are same. (Eg. 20/11/07 20/11/07 20/11/07 25/12/07 25/12/07 25/12/07 27/12/07 27/12/07 29/12/07 29/12/07 30/12/07 31/12/07 ,etc...) 20/11/07 is 3 data. 25/12/07 is 3 data. 27/12/07 is 2 data. 29/12/07 is 2 data. 30/12/07 is only one data. 31/12/07 is only one data. I wanna display the above data onto a ComboBox by desending. I wanna collect only one data for a same many data. (Eg. 31/12/07 30/12/07 29/12/07 27/12/07 25/12/07 20/11/07 ... etc ) Please give me some suggestion for above metter.:confused:

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You need to check if a value is in the list already before you add it. IF you're getting data from a SQL source, use the UNIQUE keyword to get unique values.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      1 Reply Last reply
      0
      • P phowarso

        I have a table's field that "Date". It contains severial data, some are same. (Eg. 20/11/07 20/11/07 20/11/07 25/12/07 25/12/07 25/12/07 27/12/07 27/12/07 29/12/07 29/12/07 30/12/07 31/12/07 ,etc...) 20/11/07 is 3 data. 25/12/07 is 3 data. 27/12/07 is 2 data. 29/12/07 is 2 data. 30/12/07 is only one data. 31/12/07 is only one data. I wanna display the above data onto a ComboBox by desending. I wanna collect only one data for a same many data. (Eg. 31/12/07 30/12/07 29/12/07 27/12/07 25/12/07 20/11/07 ... etc ) Please give me some suggestion for above metter.:confused:

        R Offline
        R Offline
        Rajesh Anuhya
        wrote on last edited by
        #3

        hi.., i am trying to give you 2 suggestion. 1. Try to retrive the unqui date from data base. when you are retriving data from dbase base user "distinct" keyword in query Ex: select distinct mydate from mytable. or 2. use the below logic. dim innlop,temploop dim dupflad as boolen=false combobox1.items.clear For innlop = 0 To ftp_ds_NT.Tables(0).Rows.Count - 1 dupflad =false for temploop=0 to combobox1.items.count -1 if ftp_ds_NT.Tables(0).Rows(innlop)(0) )=combobox1.item(temploop) dupflag=true end if next temploop if dupflag=false then combobox1.items.add(ftp_ds_NT.Tables(0).Rows(innlop)(0) )) end if Next innlop ********* Please Ignore the syntex errors ************** thanks

        Rajesh B --> A Poor Workman Blames His Tools <--

        C 1 Reply Last reply
        0
        • R Rajesh Anuhya

          hi.., i am trying to give you 2 suggestion. 1. Try to retrive the unqui date from data base. when you are retriving data from dbase base user "distinct" keyword in query Ex: select distinct mydate from mytable. or 2. use the below logic. dim innlop,temploop dim dupflad as boolen=false combobox1.items.clear For innlop = 0 To ftp_ds_NT.Tables(0).Rows.Count - 1 dupflad =false for temploop=0 to combobox1.items.count -1 if ftp_ds_NT.Tables(0).Rows(innlop)(0) )=combobox1.item(temploop) dupflag=true end if next temploop if dupflag=false then combobox1.items.add(ftp_ds_NT.Tables(0).Rows(innlop)(0) )) end if Next innlop ********* Please Ignore the syntex errors ************** thanks

          Rajesh B --> A Poor Workman Blames His Tools <--

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          A nested loop is always expensive, and for loops are always nastier to read than for each, but in this case, just combobox1.Items.Contains would work. You could also replace the dupflag variable with a simple continue statement.

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          R 1 Reply Last reply
          0
          • C Christian Graus

            A nested loop is always expensive, and for loops are always nastier to read than for each, but in this case, just combobox1.Items.Contains would work. You could also replace the dupflag variable with a simple continue statement.

            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            R Offline
            R Offline
            Rajesh Anuhya
            wrote on last edited by
            #5

            hi..., So that i can remove one loop., nice ... , i accepted. Thanks Christian Graus

            Rajesh B --> A Poor Workman Blames His Tools <--

            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