How to collect the same data?
-
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:
-
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:
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 )
-
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:
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 <--
-
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 <--
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 )
-
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 )
hi..., So that i can remove one loop., nice ... , i accepted. Thanks Christian Graus
Rajesh B --> A Poor Workman Blames His Tools <--