|
ok, i used a few minutes ... and proofed you are right.
AND i want YOUR computer *g* both ways used 3 milliseconds on my machine
I cannot remember: What did I before google?
|
|
|
|
|
Thank you for running the test and your very helpful answer.
|
|
|
|
|
Read SlimList (I'm the author, but I think it's very relevant to your question). It discusses a bit about how List works. The List class basically uses an array that doubles in capacity each time capacity is reached. If you average out the time spent on each add operation, that comes to a performance of O(1) for each insert operation. Performing an array resize each time you add an item would average to O(N) for each insert operation (where N is the total number of objects inserted). Of course, you could reimplement the capacity-doubling functionality to make it O(1), but then you'd just be making List all over again. Read about big-O notation if you don't know what O(1) and O(N) mean.
Go with List. Read the above article if you want a more in-depth understanding of List (as well as an understanding of how it can theoretically be improved upon). Also, one more note: do not use SlimList. It merely demonstrates a theoretical improvement that is in practice so slow that it is not worthwile to with any real production code.
Steven St. John wrote: I understand that using a collection would be a bad idea because of boxing/unboxing issues, but I was given to believe List(Of T) does not suffer this penalty.
The word "collection" applies to both arrays and Lists. In either case, those collections will only suffer a boxing penalty if you try to store a non-reference type in a reference variable. For example, if you put an integer into a List(Of Object) . However, putting an integer into a List(Of Integer) would not cause boxing.
|
|
|
|
|
Thank you - your article was very informative!
|
|
|
|
|
I'm glad it helped.
|
|
|
|
|
Dear All,
Kindly advise me how can I be able to write Urdu in textboxes/listboxes/... during run time in VB 6.0. Even support for Urdu is installed on my system (CRULP URDU phonetic Keybaord) and "Microsoft Form Object 2.0 Library" is also enabled. Some others character similar to German language were usually displayed from Left to Right fashion during typing in textbox.
Regards
|
|
|
|
|
This[^] may help.
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
Hi,
I want to show alert on my windows form when a new record added to database. I want to show the no. of rows added in a link label and on clicking on the link I want to show the rows newly added to database.
Kindly suggest how this will be possible.
Thanks
Sanjay
|
|
|
|
|
You would need to poll the database, perhaps a timer or thread could be used, and check if any changes had been made. If changes exist show the LinkList. If the user clicks on the links then retrieve the record/s from the db and show them.
...and I have extensive experience writing computer code, including OIC, BTW, BRB, IMHO, LMAO, ROFL, TTYL.....
|
|
|
|
|
You could place a Timer control on your form like Wayne suggested and the code behind would be something like this ...
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick<br />
' place code here to check if a new record has been added to the database<br />
End Sub
Your request is something kind of unclear because I don't see what the real-world applicaiton would be.
If it is a dispatching system, then I would create a "Pending Tasks" list and have a function that would refresh this list on a periodic basis. The problem that I see is ... "What is considered a new record and what are you going to do with it?" You might need to flag it in some way that the record has been processed. What if your window application is not running and someone adds a record to the database ?
You might want to revisit your design.
Just some thoughts
Good luck.
|
|
|
|
|
I wrote a large Database program in VB6 that worked well for many years. Now I am trying to re-write that program in VB10. I was able to figure out how to make everything work except for the main element, the Database controls. Is there something that I can read to learn how the new code works?
Thanks, Garner
|
|
|
|
|
When you say Database controls, are you talking about UI or at a data access level. An example code snippet would also help answer your question.
"You get that on the big jobs."
|
|
|
|
|
Now I think I’m worse off than I originally thought since I don’t even know how to answer your question. Guessing “UI” means “User Interface?” If so, I think that is where my problem is.
Here’s the old VB6 code I used for my “Update” button in the user interface. VB10 highlights just about all of it with all kinds of errors. The worst part is that I have several buttons in each of several interfaces controlling several databases. “Add,” “Update,” “Delete,” & “Refresh” are the buttons that I am using.
Private Sub cmdUpdate_Click()<br />
On Error GoTo UpdateErr<br />
<br />
Dim db As Database<br />
Set db = OpenDatabase("c:\microsoft visual studio\vb98\openaccts.mdb")<br />
<br />
Dim rs As Recordset<br />
Set rs = db.OpenRecordset("prices", dbOpenDynaset)<br />
<br />
'Edit record and show new prices.<br />
<br />
rs.Edit<br />
<br />
rs.Fields("1b") = txtFields(0)<br />
rs.Fields("2b") = txtFields(1)<br />
rs.Fields("2r") = txtFields(2)<br />
rs.Fields("3a") = txtFields(3)<br />
rs.Fields("3s") = txtFields(4)<br />
rs.Fields("as") = txtFields(5)<br />
rs.Fields("br") = txtFields(6)<br />
rs.Fields("bs") = txtFields(7)<br />
rs.Fields("fd") = txtFields(8)<br />
rs.Fields("ms") = txtFields(9)<br />
rs.Fields("os") = txtFields(10)<br />
rs.Fields("ts") = txtFields(11)<br />
rs.Fields("tu") = txtFields(12)<br />
rs.Fields("ws") = txtFields(13)<br />
<br />
rs.Update<br />
<br />
'Change prices on PRODUCT form.<br />
<br />
frmprdm!txt1b.text = rs.Fields("1b")<br />
frmprdm!txt2b.text = rs.Fields("2b")<br />
frmprdm!txt3a.text = rs.Fields("3a")<br />
frmprdm!txt3u.text = rs.Fields("3s")<br />
frmprdm!txtas.text = rs.Fields("as")<br />
frmprdm!txtbr.text = rs.Fields("br")<br />
frmprdm!txtbs.text = rs.Fields("bs")<br />
frmprdm!txtfd.text = rs.Fields("fd")<br />
frmprdm!txtms.text = rs.Fields("ms")<br />
frmprdm!txtou.text = rs.Fields("os")<br />
frmprdm!txtts.text = rs.Fields("ts")<br />
frmprdm!txttu.text = rs.Fields("tu")<br />
frmprdm!txtws.text = rs.Fields("ws")<br />
<br />
Exit Sub<br />
UpdateErr:<br />
MsgBox Err.Description<br />
End Sub
I have read a ton of information online about changing the code and; so far, none of it has worked for me.
Thanks, Garner
|
|
|
|
|
Read up on DataTables, DataSets and DataRows - that should help.
|
|
|
|
|
As mentioned ADO.NET is different to ADO but looking at that code I would recommend you may do well to use Entity Framework. It will abstract away a lot of the implementation and should fit quite nicely with your current model. Julie Lerman has created a great beginners guide screencast. If you want to get up and running fast, I'd go straight to EF - Part 1 section.
Enjoy
"You get that on the big jobs."
|
|
|
|
|
Implementation of ADO.Net is different from ADO, so you will need to read about ADO.Net and learn it before using it.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
I pretty much figured out that everything was different when none of my code worked anymore and nothing that I did helped. That was pretty much my original question. What do I read and where do I find it? I have read stuff online for hours in forums, MSDN, sample code ...? I have looked for books on the subject but I haven't found anything that seems like it would help. In VB6 I went to the book store, picked up a book, "Visual Basic 6 Database Programming," and everything I needed was there. No such luck with VB10.
|
|
|
|
|
Here's a link to Amazon.com ADO.NET on Amazon[^]
Some in the list are specific for VB.
Julia Lerman's book is also mentioned and, like Rob above, I would recommend going the Entity Framework route as you then have an abstraction layer over the ADO.NET itself.
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
Thanks everyone for all of the information! Now I will have to see if my mind can absorb enough of it to make my code work. If not I know where to come for more help.
Thanks again, Garner
|
|
|
|
|
How to use WIA.dll to scan from adf in scaner
|
|
|
|
|
A little Google goes a long way, especially if you follow the first link in the results.
BTW: It took me all of 4 seconds to find this.
|
|
|
|
|
Hi everyone,
I have a listbox derived from a table with the following record:
Listbox_answer_item
Bleu
Red
Black
this is from an answer table base on a particular question. since a question can have more than one asnwer, I like to number the response to a question
I rather show the items in the list box in sequential manner with a numbering system.
For example:
Listbox_answer_item
1. Bleu (first answer)
2. Red (second answer)
3. Black (third answer)
4. etc..
this number should be a position number..which answer that enters first and so forth..
Thanks in advance!
|
|
|
|
|
I think this is what you are asking for
VB.Net
Dim answers() As String = { "Bleu", "Red", "Black" }
For I As Integer = 0 To answers.Length - 1
ListBox1.Items.Add((I + 1).ToString() + ". " + answers(I))
Next
VB6
Dim I As Integer
Dim answers(2) As String
answers(0) = "Bleu"
answers(1) = "Red"
answers(2) = "Black"
For I = 0 To UBound(answers)
List1.AddItem CStr(I + 1) + ". " + answers(I)
Next I
To add more answers to the listbox, just add more elements to the array.
|
|
|
|
|
Hi,
Thanks for replying. these answers are from a Question_Answer table relationship.
The listbox is binding with Qestion_Answer table based on Question_PK and Answer_PK.
so the answer is not hardcoded. I want to enumarate the answers on the listbox.
Thanks again.
PS. vb.net and sql
|
|
|
|
|
You should be able to use the ListBox Format event to solve this problem.
Some rough and ready code showing the general idea
Private data As String() = {"One", "Two", "Three", "Four"}
Public Sub New()
InitializeComponent()
addhandler listBox1.format, addressof listBox1_Format
listBox1.DataSource = data
End Sub
Private Sub listBox1_Format(sender As Object, e As ListControlConvertEventArgs)
Dim list As IList = DirectCast(DirectCast(sender, ListBox).DataSource, IList)
Dim idx As Int32 = list.IndexOf(e.ListItem)
' format as "1. One", "2. Two" etc
e.Value = String.Format("{0}. {1}", idx + 1, e.ListItem)
End Sub
Alan.
modified on Friday, June 17, 2011 10:37 AM
|
|
|
|