Pass More Than 2 Argument To Events
Nov 10, 2009Can we pass more than 2 argument to our events, tell me in brief about Events
View 1 RepliesCan we pass more than 2 argument to our events, tell me in brief about Events
View 1 RepliesDoes the following work in VB 2008 for passing an array to a function:
Public Function functionname(ByVal array1() As Short, ByVal array2() as Short) As Short
Also, can ByRef be used in place of ByVal?
Private Sub SpecialMenu( ByVal ddItems As ToolStripItemCollection, method as ??)
...
AddHandler ddItems(item).Click, AddressOf method
...
How can I pass a sub address into a subroutine.
I understand delagates but not enough to figure this out.
I have a sub that creates and adds menu items to a menu and I need to use it in more than one project so I want to put it into a library.
But I don't know how pass it the address of the subs to attach to the new menu items.
I am trying to pass an argument to a sub then have it add to my listview, my code is:
Module modFunctionsSubs
'Function and sub routines
'This sub logs an even in the listview
Public Sub logEvent(ByVal statusText As String)
listViewMainLog.Items.Add(statusText)
End Sub
End Module
My argument is getting through ok, statusText but I get an error:
'Name listViewMainLog is not declared'
I've got several user controls and every time I add them, I post this
Dim uc As New ucTemplates ' 'ucTemplates' is the name of the actual user contrll
gbControls.Controls.Clear()
gbControls.Controls.Add(uc)
So, I'd like to create a sub that does the same thing, passing the usercontrol as an argument
Private Sub AddUC(myControl as UserControl)
gbControls.Controls.Clear()
gbControls.Controls.Add(myControl)
End Sub
But - when I try:
addUC(ucTemplates)
I get an error that ucTemplates is a type and cannot be used as an expression
I can get it working if I add the Dim uc As New before the addUC - but I'd rather have it so I only repeat one line, not 2
I know how to pass arguments between two dotnet applications! However I have hard time with this: I want to pass a command line argument. for example; test.exe is a console application (none dotnet) self terminating app. From cmd.exe if I type "test.exe -v" the cmd output text will display the test.exe version info. If I place the test.exe in the same path as my VB.net app.What I want to do is:
[Code]....
How, can i pass any command line arguments (Through Run Command)pass when my VB application execute and that's valuesare receive when form activate.
View 12 RepliesI have created my app to load with a argument
now, what I want to know if it's possible to pass the load argument even if app is loaded
like
app.exe -a = loads a special form on app.exe at load time
and if app.exe is already loaded to load same form if user requests it again from a shortcut or so
<p>I'm trying to use a function that takes a variable referring to various listboxes.</p><p>Something along the lines of:</p><p>Calling code:</p><p>...</p><p> Dim lstBox
as ListBox</p><p> if a=1 then lstBox = Me.ListBox1 else lstBox = Me.ListBox2</p><p> MyFunction(lstBox)</p><p>...</p><p></p><p>Called function:</p><p>
public sub MyFunction(lstCtrl as ListBox)</p><p></p><p>lstCtrl.Add()....</p><p></p>
The problem that I am facing is that I want to call a shared DLL created by qt4. Now reading the result from the DLL file is working well and good. But the problem arised while passing arguments required by the function in the dll file.The argument (both string or int) is not passed properly. Suppose I pass an integer argument 8, but 1 is passed. Whatever is my input only 1 is passed.
View 2 RepliesIn a threaded app in VB 2010, I can do this[code]...
View 6 RepliesI have several parameters consisting of separate System.Byte() arrays. What I need is the syntax for a function declaration where the parameter is an array of arrays - I do not want to delve into System.Collections, and it's my preference not to CType each array into an Object and then back into a Byte().
Problem I'm having here is that:
Public Function MyFunc(arrayparam() As System.Byte) As System.Byte()
accepts a single-dimensional Array of individual Bytes.
Then Public Function MyFunc(arrayparam() As System.Byte()) As System.Byte()
How can i pass the button click as an argument in a function.
View 6 RepliesI'm writting a class that needs the form handle but there is a way to use it without send it as argument in the class constructor or in a property?I know that the handler is not set until the form is completely loaded so that is another problem too.The basic idea is catch the form handle without pass it as argument and handle the wm messages.
View 2 RepliesI'm using VS2008, vb.net, and winforms. I've got 3 comboboxes on the same form who are all bound to the same data. If an item is added in one, I want the change reflected in the other two. I'm trying to create one sub to handle the adding of an item for all three combos. I found that the "sender" object appears to contain the control name. The Sub I created is not working quite right because after the item is added, the combo list display repeats itself. So instead of "Item1, Item2, Item3" after adding "Item3", I get "Item1", "Item2", "Item1", "Item2", "Item3". This coding works fine if I were to copy it to the Key_Down event for each combo and reference it directly (for example, use cboSpecialty1.Items.[code]...
View 4 RepliesI have 3 click events in my form. I have delcared a string variable called sVariable in the following format: Public sVariable As String but when I try to use the value from the sVariable variable then it does not pass the value to the other click events. so in the Button1_Click event i type the following
[Code]...
I am using AddHandler to wire a function to a control's event that I dynamically create:
[Code]...
This code is generating a run-time exception stating: Unable to cast object of type 'MyEventHandlerDelegate' to type 'System.EventHandler' What am I not understanding about System.Delegate even though AddHandler takes as an argument of type "System.Delegate"? What Type does "EventHandler need to be to cast to a type that AddHandler can accept?
I am trying to put a new face on an old C program. The C program is, of course, unmanaged code, designed smartly to separate the number crunching and the interface, and the interface I'm trying to replace is X windowing. The graphics part is where it gets a little hairy, because the C is going to need to continue to draw in my new interface, based on the data the program produces. Even if I want to duplicate that data in .NET so that the .NET side can handle all of the drawing, the fact remains I'm going to need to operate on the graphics window in some fashion from C.
I gather that handles have a lot to do with the bare Win32 graphic operations. Is such a similar handle provided to, say, a PictureBox element in .NET? And if so, is it the kind of handle I can use in the unmanaged code without an issue?
I have tried and tried and tried to google for the solution for weeks now, and all I come up with are either C++ solutions (using object-oriented GDI+) or some sort of extension to the C language.
Alternatively, is there a way I can have .NET create a handle specifically for this purpose of having C draw it?
To sum it up, I am using Visual Basic .NET 2008 and a C DLL (also compiled in VS2008), so far in the little testing I've done, I've been able to marshal complex structures to and fro, but I am not sure how exactly I'd let C do any drawing on the .NET form, if that was even possible.
Im a student doing an assignment, how do i pass the value from a sub procedure to a function procedure....i want to pass the value from decSubtotal to a function procedure named CalculateDiscount; check out my code--
[Code]...
I want to do something like the following in VB.NET, is it possible?
Function task(value as Object, toType as Type)
Return DirectCast(value, toType)
End Function
I made this procedure re-use a select query:
[code..]
And I use it like this if I would want the selected value placed in a textbox and it works fine
[code...]
However if I want the value to be passed in a string like so:
[code...]
The string ends up having an empty string value. How do I assign the value I queried to that String?
I have been trying to implement the jQuery weekcalendar using .net. What I can't seem to figure out is why weekcalendar states events.events is undefined after I make an ajax call to a webmethod I created which returns JSON. Below is the relevant code:
[Code]...
I want to make Keybord events and mouse events for learning and educational Purpose.
1. In Form any object like A "picture box" move by Arrow keys .
2. Picture Box Contain many Picture i want change Picture With next and Previos By Arrow keys.
3. I contain Voice of alphabet in Mp3.When i Press any button in textbox then its work.
4. Mouse Pointer Change My Own.
5. I click any Object or any thing By mouse its noice clicking sound like Tik Tik Tik.... Question No 3 is very hard to do . but not im possible
I have two tables:
table1
case_no flow result
tc_1 001 pass
tc_1 002 pass
tc_1 003 pass
tc_2 001 pass
tc_2 002 fail
tc_2 003 pass
table2"
case_no result
tc_1 pass
tc_2 fail
Table2 should be updates from table based on the results... If all results is PASS then the table2 should be updated as pass... if any result is FAIL then the entire case_no should be updates a s fail..
This code was working consistently, but now...This code works on the first pass.Then second pass it just hangs on Code:Dim tcpClient As TcpClient = tcpListener.AcceptTcpClient() for about 2 minutesThen the code will fork for another pass, then fail.....
Code:Imports SystemImports System.TextImports System.Collections.GenericImports System.XmlImports System.Xml.LinqImports System.Net.Sockets
[CODE]....
Just started VB programming this week and have found a wealth of information about what I'm trying to do. Problem is, some of it is more complete than others.Here's what I'm trying to do:In Form1 (my main form), I want to instantiate a class that contains a couple of properties (speed setpoint and position setpoint). When I click a button, I want to pass this data to Form2 and populate two textboxes on Form2 with the properties of this object. I want to manipulate the property values on Form2 and click an OK button which closes the dialog and returns the manipulated data, updating the property values of the object. Here's the algorithm I'm following:1) On Form1, instantiate the class2) On Form1's "Pass Data" button click event handler, instantiate a Form2 object and invoke the ShowDialog method, passing the object as a parameter.
3) On Form2, overload the ShowDialog method to accept the object as a parameter and modify the method so that it returns the manipulated class data.4) On Form2, in the ShowDialog method, populate the textboxes with the class data that was passed in.Here's where I get stuck. If I press the OK button on Form2 (DialogResult.OK), it returns me to Form1, but what hook do I have in Form1 to receive the manipulated class data that the ShowDialog method is returning?Here's an example of what I'm thinking about:
Code:
Public Class Form1
Dim clsController1 As New MotionController
[code].....
I'm sure it's probably a very elementary question, but every explanation I've found seems to be incomplete.
I created a control that has picture box control docked within it. This control allows me to "animate" the image by swapping them out by setting the interval to swap them at. I want to use this control kind of like an animated icon within a application, but because the picture box is docked, the control I created won't respond to the events, MouseHover specifically. [Code]
View 2 RepliesI don't know how to use these events and get the appropriate values out of these events ....here is some code that I have copied from a website...
[code]
Private Function MouseHookProc(ByVal nCode As Integer, ByVal wParam As Integer, ByRef lParam As MSLLHOOKSTRUCT) As Integer
Try
If nCode >= 0 Then
Select Case wParam
[code]....
FORTRAN allows one to use a procedure (function or subroutine) as an argument to another procedure. For example:
SUB Procedure1(x)
----
----
RETURN
[code]....
Does Visual Basic 2010 allow this functionality, directly or indirectly?
I am looking for some input. I am helping with a web application that is fairly large. We have some logic factored out into classes, not a true business logic layer (yet ). The classes are setup to pull values directly from the QueryString or Session variables and I'm not sure that that mehtod is proper or even a
The reason I would like some input is, there may be a chance to rewrite or at least refactor the code.
[Code]...