|
Hi,
Can anyone give me a sample code to remove duplicates from an arraylist?
I have an arraylist with duplicate entry and want the distinct values from that.
Thanks in Advance
|
|
|
|
|
Private Sub RemoveDuplicates(ByRef source As System.Collections.ArrayList)
Dim destination As New System.Collections.ArrayList
For Each item As Object In source
If Not destination.Contains(item) Then
destination.Add(item)
End If
Next
source = destination
End Sub
It would however be move efficient to perform the contains test on the original arraylist before inserting the items in the first place.
If you have knowledge, let others light their candles at it.
Margaret Fuller (1810 - 1850)
|
|
|
|
|
I have a project using remote access but program was wrong and not compile when i use an sql parameter as a variable to take data.
But i use string as variable thn program run.
help me
quang
|
|
|
|
|
dokhung wrote: I have a project using remote access
What do you mean by "remote access"?
dokhung wrote: but program was wrong and not compile
What is the error message the compiler is giving?
dokhung wrote: when i use an sql parameter as a variable to take data.
But i use string as variable thn program run.
Can you supply us with that section of code?
Your request was very vague. In order to get help you need to give us more information.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|
|
hi everybody.. I have a question.. i have a problem how to communicate vb with my hardware using serial port.. can somebody help me solve my problem..
areon25
|
|
|
|
|
You have at least two options depending which version of VS are you running:
VS2005: Use My.Computer.Ports class to access and use COMx
VS2003: You can use MSCOMM object or one of the available classes (also on this site)
With VS2005 look in the official MSDN documentation for code samples
With MSCOMM it's easier to find sample code (tons) with google
With User classes (there are at least three around) sample code is provided with them.
Briga
|
|
|
|
|
Hello all,
I want to write a program in VB.NET that deletes all files and subdirectories, in a directory, that are 7 or more days old, I don't know how to go about it though. Does anyone know how to do this?
Thanks in advance for any advice.
|
|
|
|
|
Hi.
Use following class.
System.IO.DirectoryInfo
System.IO.FileInfo
!alien!
|
|
|
|
|
I am assuming that you have a non-destructive purpose for this question? (i.e. you are not trying to delete anyone else's files are you? )
Before you reinvent the wheel... there are many free utilities out on the net that can do this and more. Just Google for them.
If you REALLY want to write it in code, first of all read all you can about the classes "alien viper" has already posted and understand the NTFS (or FAT32) directory structure and how it operates. There are plenty of articles on The Code Project and elsewhere on the net.
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
I'm working on an MS Access app.
The client use this app with their monitor resolution set to 800 x 600.
Whenever I edit a form I need to set my screen resolution to 800 x 600 to make sure the form is within bounds.
I wan't a fast way to set the Main Access Window's size too 800 x 600 pixels.
Application.DoCmd.MoveSize(,,800,600) is supposed to work but I get a syntax error.
Any ideas?
|
|
|
|
|
Now, i have a formula, after solving some expression i want to assign a new value to a Parameter fields.
But i dont know how to do it.
Please help me!
superdragon
|
|
|
|
|
Hi All,
In response to my post below, I got feedback from dave which was
FEEDBACK
**********
Performance will suffer each time you have to go back to the database to get the records you need.
Your best shot is to use a DataView on your DataTable so it returns all the records with at ID.
It's a different View of the table. DataViews can be reconfigured quickly so...
What you'd probably do is retrieve a small table with all the UNIQUE (hint, hint) ID's you're going to use,
then retrieve all the records that contain all the ID's you want in a seperate table.
Now, you'll iterate through the first table, with the ID's, and use each, one at a time,
to build a DataView on the second table that will return only the records with that ID.
You can then use the data in that DataView to bind to your control.
Dim dv As New DataView(dataTable)With dv
.AllowDelete = False
.AllowEdit = False
.AllowNew = False
.RowFilter = String.Format("ID='{0}'", idToFind)
.Sort = "CompanyName DESC"End With' Bind you control to this DataView
**********
MY POST
-------
I am using a webchart tool called Mycos ( A web control)
I create a single chart with following code:
MycosChartWeb1.DataSource = CreateData()
MycosChartWeb1.DataBind()
creating single chart is not a big deal if i have a standard query with no parameter called ID.
if createData() is of type:
Private Function CreateData() As DataSet
Dim id As String
objConn = New SqlConnection(dbPath)
cmd = New SqlCommand("select period,scorecard,actual,target from ShirePlan where measureID='2.1.1.1' and period like '%2003%' ", objConn)
'cmd = New SqlCommand("select period,scorecard,actual,target from ShirePlan where measureID='" & ID & "'", objConn)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet
da.Fill(ds)
Return ds
End Function
but in my case i have ID which ranges from zero to N records.
I need to create dataset for each ID like for measureID 2.1.1.1 i need to create new dataset and bind it to mycos
again for new measureID i have to do same.
Some one told me to use Dataview and someone said something i really dont know how to achieve this
------
I actually wanted a list of datasets for each ID which i want to bind to a webcontrols. i think from what dave suggested is i will only get one
get one whole set of record
eg.
dataset1 to datasetN for ID 1 to N
where N is a number from 1 to 20
dynamically.
hope its clear and hope you will make clear how to achieve this.
thanks
|
|
|
|
|
foremorecoast1 wrote: I actually wanted a list of datasets for each ID which i want to bind to a webcontrols. i think from what dave suggested is i will only get one
Yes. You will only get one DataSet. But, using DataView's, you can create as many different views of that data as you want, and bind you chart controls to those VIEWS, not the DataSet.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I have formula field in crystal report, now i want to receive value from it. How can i recieve it?
Please help me!
superdragon
superdragon
|
|
|
|
|
what is consouil programming
hi
|
|
|
|
|
U_subhu4u wrote: consouil
Did you mean console ?
chatura
|
|
|
|
|
ya
i mean what is console Programming
can u give me an example of thif programming
subhash kumar (delhi india)
|
|
|
|
|
ya
i mean what is console Programming
can u give me an example of thif programming
|
|
|
|
|
|
U_subhu4u wrote: what is consouil programming
Try Google[^]
...Steve
1. quod erat demonstrandum
2. "Give a man a fish and you've fed him for a day. Teach him how to fish and you've fed him for life." I read that somewhere once
(Translation: I'll show you the way, but not write the code for you.)
|
|
|
|
|
i am using two FORMs. Form1 and Form2
Form1 have dialogbox, menu button etc and Form2 contain Richtextbox1..
from Form1 menu i open opendialog box i want the file open and display it in form2 richtextbox.
please help me and reply me soon....
zabsmarty
|
|
|
|
|
you can use this in both VB.Net 2003 & 2005
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then<br />
Dim newForm2 as New Form2<br />
newForm2.RichTextBox1.LoadFile(OpenFileDialog1.FileName)<br />
newForm2.Show()<br />
End If
chatura
|
|
|
|
|
Hi,
I’m new to ADO.Net and I’m using VB.Net 2005. I have created a form which
has a Data Grid, a ‘Show Data’ button and a ‘Update’ button.
Also I have created a BindingSource, a TableAdapter and a DataSet. BindingSource is connected to an Access Database.
I can get data by using
Me.myTableTableAdapter.Fill(Me.DBDataSet.myTable)
But when I tried to update the TabelAdapter
Me.myTableTableAdapter.Update(Me.DBDataSet.myTable)
I received an error
“Update requires a valid UpdateCommand when passed DataRow collection with modified rows.”
Then I double clicked the ‘DBDataSet.xsd’ on the Solution Explorer window and I selected myTableTableAdapter and created a new UpdateCommand
Now I receive an error
“Command text was not set for the command object.”
I do not know what I have to do next
Please Help me
Thank you
chatura
|
|
|
|
|
First create a command builder and then update the Data Adapter.
Dim CB As New OLEDBCommandBuilder(myTableTableAdapter)
Me.myTableTableAdapter.Update(Me.DBDataSet.myTable)
With Best Regards,
Mayur
|
|
|
|
|
When I try to do that I get a compilation error
WindowsApplication2.DBDataSetTableAdapters.myTableTableAdapter' cannot be converted to 'System.Data.OleDb.OleDbDataAdapter'.
WindowsApplication2 is my project name
chatura
-- modified at 0:46 Friday 10th March, 2006
|
|
|
|