|
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Network chat is one of those ubiquitous apps that every newbie wants to make. All you have to do is type "vb.net chat[^]" into Google and you'll come up with about 4,000,000 hits, most of which have code examples of what you want to do.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Trust me, it works great! And a lot easier than networking!
Just try it!
|
|
|
|
|
UltraCoder wrote: And a lot easier than networking!
And totlay useless if the two people who are chatting are not part of the same network, like say, on the Internet!
You were wondering why nobody was downloading the stuff from your site? This could be a clue...
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
VB.NET
For my application i need to create arrays on runtime.
How will i do that?
Or do i have to make something like a method which creates an array while developing and make an instance of it at runtime to rename it finally?
Thanks
-- modified at 17:24 Friday 3rd November, 2006
|
|
|
|
|
keninfo wrote: Or do i have to make something like a method which creates an array while developing and make an instance of it at runtime to rename it finally?
I don't understand what this means.
To be honest, I don't understand your question. do you want to assign an array, or create a variable that wasn't in your code before ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Just create a method that creates your Array and call that method at runtime! Or, just put the code that creates the array in the "Form.Load" procedure.
Or do you want to know how to create an array?
|
|
|
|
|
Like Christian, I can't figure out what you really want to do. You're post sounds a bit confused.
Are you looking for something like this?
Dim myArray() As String
creates an array of Strings.
You might want to explain what your trying to do in more detail and include a code snippet showing where you want this array to show up.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Ok, maybee a wrong start of this discussion.
Let's try it again.
I am writting an application (kind of callcenter server), which controls the traffic from a telephone system (PABX).
The application let me insert callcenter agents(name and number), extentions(name and number) and callcenter groups(name and number).
When i insert a callcenter group an array has to be created with the callcenter group number as it's name. finally i can add agents to the group array.
So, for example:
Two agenst were inserted:
200 Bill
201 Albert
Then two extentions were made:
100 extention 100
101 extention 101
Finally one group is made:
400 Sales
After creating the group, an array has to be created with 400 as it's name.
The agents have to be added to the group array.
So, i know how to make an array: Dim groupArray() as Integer.
And i know how to add agents to the array.
But during runtime there have to be an array created everytime when a group is made and the array name has to be the number of the groep.
Thanks
regards
|
|
|
|
|
I think what you probably need is a dynamic array of collections, so you can add a collection every time a new group is created.
Hope this helps
Chandra
|
|
|
|
|
Ok,
But how will i do that?
|
|
|
|
|
It sounds like you looking more for a database than a collection of arrays. You've just described the layout of three different tables and their relationships.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Yes, i can imagine.
But i want to solve this with arrays.
|
|
|
|
|
Google this: "jagged arrays vb .net"
|
|
|
|
|
So you say that you need to create variables dynamically? Well, that's not possible in VB.NET. Why? Because noone ever needs to do that. Ever.
You say that you need to create an array that has a specific name. Strictly speaking that is not possible either, as an array doesn't even have a name.
When you create an array object you get a reference to the object. That reference is usually assigned to a reference variable. For example:
Dim a As String[] = New String[42];
Here the statement New String[42] creates the actual array, and the value of that statement is the reference to the array. The variable a can hold a reference to an object of the type String[] . The reference to the array is stored in the variable.
You can have any number of references to a specific object. Example:
Dim b As String[] = a;<br />
Dim c As String[] = a;
Now you have three references to the array, but there is still only one array. You have three references with different names, and the array doesn't have a name at all.
---
b { font-weight: normal; }
|
|
|
|
|
OK. Here's what you need to do. Or what I would do.*
I would use a HashTable of ArrayLists. Quick, easy, efficient, fairly robust, good cost/benefit ratio. Downside: Not strongly-typed.
You don't want to use raw arrays because you would either have to oversize them to begin with (how many? 1000? 5000? Wasteful and error prone), OR you would have to keep ReDim'ing them (bad performance). You could use ArrayList to get around that problem, but you still have no good keyed access to your entries.
That's where the HashTable comes in.
The HashTable (or Dictionary<..>, depending on your version and requirements) simply stores entries of Key and Value pairs.
In this case your Key would be the Call Center number, and it's Value would be an ArrayList.
The ArrayList would store the Agent objects.
Every time you hit a new call center, you create a new hashtable entry using the call center number as the key, and a new arraylist with the Agent on that call as it's initial value, which effectively allows you to "create a new variable at runtime with a particular name".
(Or, instead of storing the agent object in the arraylist slot, you could create a hashtable of Agents, and just store a reference to that agent's entry in the arraylist slot.)
How do you know it's a new call center? By using the ContainsKey function of the hashtable, or by simply trying to access the item with that key. If it doesn't exist, you get back Null. If it does exist, you add the agent (or a reference to the agent) to its arraylist. Simple.
If you're not familiar with hashtables, take an hour or so and read up on them. Set one up and play with it. Don't be afraid of them. Very powerful tool.
*Now. All that having been said, this is NOT the only way or best way to engineer this, it's just a quick-and-dirty as far as I look at it.
Keep in mind what Dave K. said. What you're really doing here is modeling and managing entity relationships. Call Centers, Agents, Calls, Extensions...
Which means you might be better served to use a strongly-typed DataSet, with Tables and DataRelations to begin with. You are probably going to need to do that eventually anyway.
Hope this helps. Good luck.
|
|
|
|
|
Hello OldWarhorse,
Thanks a lot for your tips.
I will try the hashtable.
Regards
|
|
|
|
|
Hello, i'd like to know that does the MMControl exist in vb.net? if so...where do i add it from?
thanx in advance
|
|
|
|
|
The windows Media Player control is probably what you mean, you may need to add it to the toolbox.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
I was wondering the same thing, but you can't add the media player control to the toolbox.
|
|
|
|
|
Why not? It works for me.
It's as easy as right-clicking the ToolBox and picking "Add/Remove Items..." under VS.NET 2002 and 2003 or "Choose Items..." under VS.NET 2005. A dialog opens up, click on the COM tab, find Windows Media Player in the list, put a check mark next to it and hit OK. Standard stuff for any COM-based component...
You've been giving out a bunch of bad advise. How long have you been doing this?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
You can add the Windows Media Player control to the ToolBox by doing this[^].
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Im not sure if windows media player and MMControl are the same thing. Cos i found a tutorial on adding sound recording to vb.net program and it used MMControl for recording sound....
|
|
|
|
|
True, but that's about as close as you're going to get without installing VB6.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I hope I don't insult anyone but I am trying to get any (if any) help developing for DocuCorp Product specifically the Documanager. THe company I work for currently is trying to migrate the thin client application design by the vendor(Docucorp) to upload and store files in this server. the problem is that this so call thin client was desing in believe or not using dynamic HMTL + a pseudo ASP calls. They provided documentation how to use their so call COM objects (and again believe or not i think they are vb5 or vb6) base code. We are tying to migrate this whole obsolete architecture to a more strong and robuted concept desing but so far nothing. Found out that their vb? libraries are not .NET interop which makes my project even difficult to get it going.
Has anyone out there done anything with any Docucorp product?
Just wonder
Thanks
Tony
|
|
|
|