Control Arrays - Allocating Multiple Camera Objects Dynamically
Jan 19, 2009
I have a VB.NET application and use some third party (closed source) ActiveX controls. One of the controls represents a "camera" (connected over several interfaces) and I try to write an example how to work with several cameras in one application. To do this I allocate multiple "camera" objects dynamically as an array which works as expected like this:
Const NUM_CAMERAS = 2
Private MyCameras(NUM_CAMERAS ) As xxx.MCamera
But the camera objects needs to be allocated with WithEvents because they raise events when a new image was taken. I found out that WithEvents variables cannot be typed as arrays and this is a pretty common problem so I also found some workarounds: [URL]. This is already pretty good and I adopted this to my concept. So I have a MyCameras array and a MyCamera all "without Events", first allocate a new MyCamera object, add a event handler and then put it into the array.
Unfortunately I get an error when calling
AddHandler Camera.ProcessModifiedImage, AddressOf MyHook
Normally "MyHook" is declared as
Private Sub MyHook (ByVal sender As Object, ByVal ModifiedBuffer As xxx.ProcessModifiedImageEvent) Handles Camera.ProcessModifiedImage
Like in the "Button examples" I just removed the "Handles Camera.ProcessModifiedImage" but I get an error that "MyHook" has not the same signature as the Delegate
Delegate Sub ICameraEvents_ProcessModifiedImageEventHandler(ImageIndex as Integer)
I have the read the article "Creating Control Arrays in Visual Basic .NET" (link: [URL]) and I its very good and useful code for 1D array of objects. What if someone wants to make a 2D array of control objects. For example creating a "table" of 8x8 buttons that will be able to change properties by using the arrays x-y coordinates. Something like button(x,y). backcolor.black or similar.
I can usually find the answers to most of my questions via the Google Gods, but not this time.I have a form that has a TabPageControl and on that page a collection of labels and text boxes via a usercontrol.
On the form I have a button that allows the user to create a new tabpage, when the code adds a new page, it automatically adds the UserControl collection. I can't get my head around how to access the objects on the newly created tabpage.
What I need to be able todo is take the index of the tabpage that has focus and translate that against the UerContol name, but I havn't a clue how to do it!
I want to take picture directly on my employee database form. I means, how to control digital camera from Visual Basic form? how to take picture through VB Command button.
What is the VB.NET syntax for declaring the size of an array of objects at runtime?To get an idea of what I mean, here is the code so far:
Private PipeServerThread As Thread() Public Sub StartPipeServer(NumberOfThreads As Integer)' ??? equivalent of C# ' ??? PipeServerThread = new Thread[numberOfThreads];
I am reading data from an excel spreadsheet and i want to create several arrays to save the data in (according to how many rows of data i have which is an unknow untill i actually read the sheet).
I have 1 computer (have usb camera) and 1 laptop ( have vb.net). How I can control that camera using wireless from my laptop to other computer using vb.net.
In C#, one can create an array of anonymous objects with new []. This was not supported in earlier versions of VB.NET, but a comment by Chris Dwyer in another StackOverflow post suggests to me that it might be supported in VB.NET 2010. I haven't been able to confirm this though.
With the following code, I'd expect to get the array elements back that I put in. Instead, the last array element, is output three times.e workaround would be to dimension the array explicitly to hold four strings, but I used this contruct all over my VBA code and I'd rather know why it doesn't do what I expect.
Sub test_d() Dim youvegotitems(100) As Object Dim v(4) As String
This probably sounds daft, but im struggling to get to grips with Classes/Modules/arrays and objects, as well as there uses and what they are, and yes im still coding some how i hear you cry.The reason i ask is because Ive got a load of Dim's in my program that are the same giving locations of files and folders and wondered can they be used as a module that i can alter after the program is built, incase of folder locations being wrong or moved, manually correct after install.
I have a vb.net application that loads in a 155mb XML file, on my machine (Dual Core, 4gb ram) this process takes under a minute however the same process has is known to take up to 45 minutes on other machines, I have traced this down to the amount of ram available on the machine. I was wondering if there is a way to give memory priority to my application?
I basically want to do what you can do for controls like the textbox where adding a new textbox automatically autonumbers itself based on the existing textboxes(e.g. textbox1,textbox2, textbox3) except for an array or some other comparable instrument.
Is there a way to dynamically create an object using a string as the class name?I've been off VB for several years now, but to solve a problem in another language, I'm forced to develop a wrapper in this one. I have a factory method to dynamically create and return an object of a type based on input from elsewhere. The provided input is meant to be the class name from which to create an object from. Normal syntax means that the entire class has to be explicitly spelled out. To do it this way, there could literally be hundreds of if/then's or cases to handle all the available class/object choices within the referenced libs:
If c_name = "Button" then obj = new System.Windows.Forms.Button If c_name = "Form" then obj = new System.Windows.Forms.Form ....
I would like to dynamically create an object (in my case a thread) and then be able reference that object. Simplistically put, I would like to read from a text file and then process each item using a thread (so that I don't have to wait for each item before starting the next). The problem is that I cannot think of a way to create a new thread dynamically ie. thread name so that I can then wait for all created threads before doing something else.
Is there a way to dynamically create an object at runtime?Background: Basically i have an employee class that i want to instantiate every time an employee logs in. What i don't want it to have an employee object already created for every employee, but when they log in the object gets created.
Is there a tool in the toolbox that i can use that replaces checkboxes. i have limited amount of space and checkboxes just keep taking up room. I need the user to select multiple objects like checking multiple checkboxes.
Problem in VisualBasic 10 on Windows 7 OS I have a form which has 30 lines for user input in format <textbox for Name> <comboBox for Type> <comboBox for Quality> <NumericUpDown for Amount> At the start of each line is a CheckBox. The intention is this enables/Disables the line. I have associated each object with an Array - eg
Dim Name(30) As Textbox etc and assigned Name(1)=Name1
[code]....
ie enable/disable the boxes on a line dependent on whether CheckBox is Checked The Sub for Picked_Changed refuses to allow referenced to the arrays within, even if not generated by the picking of box (see above - it allowed '=Men3.Value' but not 'Men(3).Value', although the button sub is fine with this)
Trying to dynamically add Alien objects (Picture boxes) to my game form. The picture boxes are invisible when I run the game. All of the other controls for the picture box seen to work just fine. Movement, Alien Shots ,etc, etc. [code]
I need to let the end user move and resize objects (like a textbox or button). There are several examples that demonstrate this in VB, but not in VB Express 2008, based upon VB.net.It looks like earlier you needed to access Windows API, but these calls does not work in VB.net. I understand that these call are replaced by "native" .net calls, but I cannot find any that does the job.
A typial example from old VB is:
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
I'm creating a certain number of objects based on some templates that I have available to the user. Then, I have a module created for each template where I will be doing some math operations, etc.
I know how many objects will be created, but of course visual studio doesn't at design time.
Dim newhydzone As PictureBox newhydzone = New PictureBox newhydzone.Name = "Zone" & Form1.hydzonecount
I used the tool about 3 years ago to create the classes for a webservice client to send or recieve arrays as complex data. Now i have to update these classes, since there are additional informations, that have to be exchanged. When i use the tool now with the new wsdl-files, it does'nt create the classes for complex data (structur, IGCTMObjectFactory), but only one class for simple data. In addition i have to establish a new client, that sends an array of complex data and receives another array of complex data. I tried to build the classes manually combining the client that sends an array with the client, that receives an array, but I failed.
Access objects on a dynamically created UserControl an a dynamically created tab page. I can usually find the answers to most of my questions via the Google Gods, but not this time. I hope the collective that is StackOverFlow can help! I have a form that has a TabPageControl and on that page a collection of labels and text boxes via a usercontrol.
On the form I have a button that allows the user to create a new tabpage, when the code adds a new page, it automatically adds the UserControl collection, all good so far. I can't get my head around how to access the objects on the newly created tabpage. What I need to be able todo is take the index of the tabpage that has focus and translate that against the UerContol name, but I havn't a clue how to do it! [Code]
I am trying to add some scripting to my VB.NET 2010 Windows Forms Application.I have figured out how to compile and execute VB.NET code stored in an external script file from within my app using Microsoft.VisualBasic.VBCodeProvider.CompileAssemblyFromSource and InvokeMember. I can also pass and return parameters to the code in the script file.In VB6 using the VBScript Host control, I could expose instances of objects in my app to the code in the VBScript.How do I do this in VB.NET?I'd like to expose a form object (the main form for my Windows Forms Application) to my VB.NET script.I don't want to pass the form as a parameter via InvokeMember.[code]
I dynamically (by programming text, not drawing in GUI) created a matrix of 10x10 buttons named 'Button1' till 'Button100'. In a formula I calculate a number, say '87'. If I next want to reference 'Button87' and change e.g. the background clolor and text properties, how would I do that? I am creating a PocketPC game using VB2005.
I created a custom class for a custom object. I instantiate like so[code]...
Now, I have two problems. First, right now this is just overwriting the same object properties, again, and again. I need to somehow dynamically name the object. Then, I need to place these objects in an array so I can iterate through them...
I have a people table which stores pupil information and a class table which stores class information. The people table has a foreign key to the class table called ClassID. although this isn't actually a master/detail situation i've coded my form following master/detail principles(using JMcilhinneys great example) so that I can select a class from a combobox and then add pupils to a datagridview, and the selected classid would be pushed through when saving. here is my
I am writing a game editor, and have a lot of different "tool" objects. They all inherit from BTool and have the same constructor. I would like to dynamically populate a toolbox at runtime with buttons that correspond to these tools, and when clicked have them create an instance of that tool and set it as the current tool. Is this possible, and if so will it be better/easier than creating those buttons by hand?