Passing/Infering Type Through Shared Function Calls?
Dec 6, 2010
how to pass system.type or a generic without much luck. I have two functions below one that works and the other that doesn't. I can't seem to make heads or tails of the VB syntax required for doing what I want to do.
' This function does not
'
' Also attempted it like this
' Public Shared Function UnserializeFromJSON(ByVal obj As String, ByRef ty As System.type)[code].......
View 2 Replies
ADVERTISEMENT
Apr 27, 2009
What will happen when 3 function calls same function at a time? I have 3 Function, f1,f2,f3.. Those function after completing their task will call finish() function. What will happen if Finish is Called morethan once..
View 9 Replies
Jan 12, 2012
I want to get a list of all students who were at one of two events. Here's my function to get an attendance list:
Private Function AttendanceList(ByVal Mode As AttendanceListLookupMode, ByVal AttendaceTypeID As Integer, ByVal EventID As Integer, ByVal EventOccurenceDate As Date) As IEnumerable(Of Integer)
'Get the attendance table for specified event[code].......
View 1 Replies
Jun 12, 2009
I'm having some trouble finding the syntax for making function calls to unmanaged DLLs in VB.NET. Let's just assume there's a function "Connected" in unmanaged DLL "Connector.DLL". I want to call this function by creating an abstract function call to it.
I've seen some code out there that looks something like
[DllImport("Connector.DLL")]
Public Shared Function Connect(ByVal intPort)
But that syntax doesn't work for me.
View 2 Replies
Nov 4, 2010
I have been thrown in at the deep end with an existing VB.NET project at work. I have never used VB.NET before so I am struggling a little. Does anyone know how to solve the following.I need to pass an instance to client side and then pass it to a shared method in order to access instance methods from when the shared method.The starting point is a fileupload control within the HTML of my Contacts.aspx file:
<asp:FileUpload ID="DocUpload1" runat="server" onchange="CallMe();" />
The onchange event calls a javascript method, see below, this uses AJAX PageMethods to called a Shared method in my code behind This is the script code which is in my Contact.aspx file
[Code]...
If anyone knows the solution please could they update the code as I probably won't be able to understand if you just give a description. I just hope I am along the right tracks.
View 1 Replies
Apr 23, 2012
Public Shared _formRef As frmMain
Public Shared f As frmMain
Class Server[code].....
but once firing off the code i get the error you see in my image attached.
View 1 Replies
Jan 8, 2010
I am looking for a utility/tool to convert calls to legacy VB6 functions to the .NET equivalent. For example, it would convert this...
[Code]....
Does anybody know of one, or am I going to have to roll my own?
View 3 Replies
May 27, 2011
I tried to search forum topics to find a tutorial that will guide me on how to achieve this however seem like most of the tutorials i were finding were confusing me more.With that being said here is what i have,Here is what I am trying to do [URL]that tutorial is exactly what I am trying to achieve however I do not understand what the supplierstableadpater, northwindtableadapters are. I can only assume that I am not doing exactly the same thing as that tutorial.
What I have is a simple sql storedprocedure that selects all employeedetails.And also another sql stored procedure that selects just a few columns from the employees table. On my frist page I am going to list all the employee names in a gridview and when they click the employee name it should take them to another page and show that employee's details. Seems like you have to use an object datasource to achieve this but is there an easier way to achieve creating a class that calls the 2 stored procedures that I have that i would be able to then link them with an objectdatsource?
View 1 Replies
Oct 21, 2009
I have a List(Of AddlInfo) with AddlInfo being an object. I'm trying to pass addlInfoList by reference into a function of another class:
[Code]...
This works if I'm not passing the reference into another class, but when I try to do this, I get the following error: Overload resolution failed because no accessible 'Sort' can be called with these arguments:
[Code]...
View 1 Replies
Jun 7, 2011
I have a storedproc accepts parameters in XMLtype as
CREATE OR REPLACE PROCEDURE GetDetails(
p_para IN XMLTYPE,
[code].....
View 1 Replies
Jan 8, 2011
In vb.net, it is possible to design a function which can operate on generic parameters which meet multiple constraints. For example, it is possible to have a function accept as a parameter a class which inherits from Control and implements IList. This function could use "Control" or "IList" methods on such an object, and also pass the object to anything that expected a Control or an IList [note that this particular combination was chosen to facilitate a brief example, not to be a particularly useful combination].
[Code]...
This approach provides compile-time type-safety; there's no need for a cast that could fail at runtime. An alternative approach would be to pass the argument as either a Control or an IList, and have the function cast to the other. That would, however, fail at runtime if the object that was passed didn't in fact meet both constraints.
Under what circumstances is it good to use a generic function like the above, in what cases would it be better to have objects which are going to meet both constraints have a new interface like IListableControl(Of T) which would include a TheControl property that would return itself (cast as a control), and in what cases would it be better to have a generic ISelf(of T) interface, any implementor of which would be expected to provide a "Self" property that would return itself as a T?
Using multi-constrained generics, it's possible to do a lot of things without requiring any run-time typecasts, but I don't know what the performance costs are likely to be. I tried writing a short program to generate 65,536 different generic types at run-time, e.g. Foo(of Bar(Of Foo(Of Foo(Of Bar(Of Foo(...(Of Blah)) and it got pretty slow, so I can tell that the time required to handle generics isn't fixed, but I don't know what factors affect it.
View 1 Replies
Jul 27, 2011
I have a camera for which the complete source code with header files(.h) and all libraries files(.lib) are given in VC++. Now if I want to access the function calls in the header files and in turn the functions in the library from VB.NET, I am required to write a wrapper DLL for accessing the function calls which I never did till now.
View 1 Replies
May 8, 2010
What the Win32 API is? I have looked around but no where really outlines what it is. Is it basically a set of procedures, outlined by Microsoft for programmers in order to get services from the operating system? In essence is it the equivalent to making system calls abd and library calls in UNIX? And yes I now Windows makes library calls too.
View 2 Replies
Mar 1, 2011
i have a function that i have in my data access class now i want to access it then declare and assign parameters and then insert data into database?
'1
'the function
Public Shared Function InsertNewRecord(ByVal myStoredProcedure As String) As Boolean
Dim conn As New SqlConnection
[code]....
View 4 Replies
Mar 4, 2010
I have been using DBTransaction for my current projects that access a single database. However, I read some documentation on TransactionScope and was wondering in which scenario would using TransactionScope be better? Or should I be replacing DbTransaction calls with calls to TransactionScope?
View 2 Replies
Nov 29, 2011
I'm wondering if this is possible. In my Test function below I want to
Check if T is of type BaseClass; throw an error if it's not.
Get the value of SomeText property of BaseClass.
Class BaseClass
[code].....
View 2 Replies
May 31, 2009
i am beginner about general programming. Please give me basic shared functions .
I only know few functions such as : Public Shared Function lon(ByVal a As Integer, ByVal c As Integer) As String Public Shared Sub trung()
View 1 Replies
Jan 24, 2011
VB.NET 2010, .NET 4. I am working on an application for controlling an industrial machine composed of many devices attached to the computer. Most if it is reasonable straight forward, but I'm having trouble thinking about the RS-232 devices. One of the RS-232 devices is a fancy power supply with many functions. The ones that are relevant right now are voltage read, voltage write, current read, and current write. The design pattern I'm trying to implement is one in which each attached device is represented by an object that has methods for reading/writing etc and properties for things like COM port etc.
For this power supply, clearly the Port reference should be shared among the instances, so I have a base class (say, PowerSupply) with a Protected Shared Property Port As IO.Ports.SerialPort. Then I have a couple classes that inherit from this class, PowerSupplyVoltage and PowerSupplyCurrent that each define read/write methods and properties for holding the last read/written values. My issue is in parsing the response from the power supply using the Port.DataRecieved event on the shared SerialPort object. The protocol the power supply uses specifies what data it's sending in each response packet.
So, basically, it might say something equivalent to "The voltage is 100V" or "The current is 1A" or "The voltage has been set to 150V" etc. I'm trying to parse this in a shared function. Only during the parsing process would I determine which instance's read/written value to update. I can't access the read/written value properties of the instances from within the shared function. The best I could think of is creating some kind of PowerSupplyCommunicator object that would maintain references to PowerSupplyVoltage and PowerSupplyCurrent instances along with the shared Port and DataRecievedHandler functions.
View 1 Replies
Dec 30, 2009
how I can dynamically load a control inside of a shared/static function?The function itself is inside of a mustinherit/abstract class.(It's an ASP.NET project in VB) I want to do something like this:[code]I'm getting "Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.",but I don't understand this error.I understand what it means, I just don't understand why calling LoadControl isn't seen by the compiler as being an explicit instance of the class. What's not explicit about using LoadControl to create a new control from a file? I tried creating a new user control and initializing it, then setting it to a different control with LoadControl to no avail.I also don't want to do a DirectCast because I'm trying to put this in a shared, mustinheret (abstract) class, which therefore doesn't have an .aspx file to write in a <%@ Reference Control="~/SomeControlPath.ascx" %>, so the class name is unavailable.What I'm trying to do is write a static function that takes some value and returns a control based only on that control's source file location.The end result is a user-modifiable list of controls.They get a column of controls that they freely add, remove, or reorder based on a static list of available child controls that I specify.
View 4 Replies
Feb 16, 2011
I can create classes that use generics, however I was wondering if it is possible to apply this to a shared method rather than rely on the caller casting to the correct type.This is the method:
Public Shared Function DeserializeObject(ByVal serializedXml As String, ByVal givenType As System.Type) As Object
Dim serializer As New XmlSerializer(givenType)
Return serializer.Deserialize(New IO.StringReader(serializedXml))
End Function
I'm pretty sure this can't be done, but thought I'd check (if so Extra points will be awarded if someone can technically explain why the compiler can't do this)..
View 3 Replies
Aug 6, 2009
I made the changes from this:
[code]...
to this:(the 'End Function' says "Function 'GetFolderPath' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used."
[code]...
View 4 Replies
Mar 29, 2010
xplain to me or give me an example of using a select case in a shared function
View 2 Replies
Jan 27, 2009
What's the advantage of declaring a function as "Shared"? I've noticed that it doesn't require you to instantiate an object to use the method when it declared as "Shared". Is that the only upside?
View 3 Replies
Nov 26, 2010
How do I get using reflection the most generic type from a shared constructor in the base class :
Public Class Foo()
Shared Sub New()
'Here we have code to get the type[code]....
I expect the result to be Bar type and not the Foo. Is it possible?
View 1 Replies
Mar 1, 2011
[Code]...
i have a function that i have in my data access class now i want to access it then declare and assign parameters and then insert data into database.
View 4 Replies
Aug 20, 2010
I get this error: Cannot refer to an instance member of a class from within a shared method or shared member initializer without an explicit instance of the class.
Partial Class _Default
Inherits System.Web.UI.Page
<WebMethod()> _
[Code]....
I know it has something to do with the fact that the first function is shared and the second function should probably be Public as well but I don't fully understand the reason behind it. Probably not relevant but I'm calling the web method from some javascript.
View 1 Replies
Jan 24, 2012
I have as sub that is triggered from the file system watcher when the new file is created in spec. directory.I need to call some function to do something with that file. [code]
View 6 Replies
May 11, 2012
i created a dll file using vb.net then it has a shared function that will execute a stored procedure of mysql but my code is something long and when accessing it, it has a big risk that it can produce an error if there is an incorrect string input, i am asking an advice how i can make it much better or can point me something much better than my code as my reference.here is my codefirst i created a function named mysqlParamDatatype wiith 1 parameter, this function will detect the mysqldatatype of the mysql sproc parameter so it can pass the value with the correct datatype. but it is to long.
Shared Function mysqlParamDataType(ByVal i As Integer) As MySqlDbType
If i = 1 Then
Return MySqlDbType.Binary
[code].....
View 1 Replies
Nov 4, 2011
I have a bunch of classes that all contain a Shared ReadOnly Dictionary. If I want to access that Dictionary when the class is a generic type (such as when I have a wrapper function that takes T as an interface that all of these classes implement), what's the way to do it?
I want to do something like GetType(T).GetMember("Dict"), but that will return a MemberInfo type, and that cannot be cast to a Dictionary of my defined type(s). For calling functions this way, one can use a delegate + CreateDelegate + GetMethod. But there doesn't seem to be an equivalent Create*for GetMember stuff. Or am I missing something?
If I plug the GetMember call into the immediate window, and then use a subscript as if it is an array, then the debug output says I am getting a Dictionary back. But if I use that same approach in the actual function that I am trying to write, then I get an error about System.Reflection.MemberInfo cannot be converted to Dictionary(X, Y)
View 2 Replies
Jun 22, 2009
I'm not sure if I'm going mad, it's always a possibility. But is it possible to call a shared member of a class given its 'System.Type' object?
View 4 Replies