Extension Method Doesn't Work
Jul 5, 2010
I wanna create extension method for IEnumerable(Of FileSystemInfo). However, compiler says "'Sort' is not a member of'System.Collections. Generic. IEnumerable(Of System.IO.FileSystemInfo)". What is strange is that IntelliSense shows this method. Where's error? [code]
View 1 Replies
ADVERTISEMENT
Apr 20, 2010
I have the following extension method. However, when I type "File." this method doesn't pop-up. What did I wrong?
[Code]...
View 1 Replies
Sep 17, 2010
I made a library in C# and I've been told by people that one of mine methods don't work in VB.NET as extension [UR]
this is the method:
public static PropertyDescriptorCollection GetProps(this object o)
{
return GetProps(o.GetType());
}
View 1 Replies
May 29, 2012
i copied
' This example demonstrates the
'Console.CursorLeft and
' Console.CursorTop properties, and the[code].....
the code straight from the source <<< a couple of pages back thataway i'm getting a build error about the users ameappdataloca emporary projectsfile.exe not found.VB Express 2008 on Windows 7. how to output text to different parts of the screen.
View 4 Replies
May 8, 2009
I am trying to post simple data to some site, in this example to a php file on my local server. My VB.NET Code:
Dim W As New Net.WebClient
Dim A As String = ""
W.Encoding = System.Text.Encoding.UTF8
[code]....
so, when I start the VB.NET App, it just simple calls the p.php (GET) but POST doesnt work. Tried everything. Upladed the p.php to other servers, checked other variables in php ($_REQUEST), used the UploadString(URL,"POST","bla=test), used PERL, ASP.. nothing.I am using .NET Framework 3.5 how to Post data with vb.net?
View 1 Replies
May 27, 2009
I can't figure this out. I have a bitmap that will be used throughout an application, so I can't declare it with a Dim statement in a procedure, or it isn't recognized as having been declared in other procedures. So I declared it at the top of the form class, two ways. This one works: Private MyBitmap As New Bitmap(622, 461) It makes a bitmap to the exact size of a picturebox I have. But I want to be able to change the size of the picturebox and not have to worry about going back into this declaration to set things up, every time I decide to change the box's dimensions. So I tried this next version, but it doesn't work:
[Code]....
View 14 Replies
Jun 11, 2012
I've got a simple tool written in VB in VS 2010 that has a series of command buttons which run Windows command files and the output is sent to a Rich textbox object on the main form (the comand files take awhile to run so I wanted the output to show up in the RTB as it was produced to show progress). All worked well until I made an update to the tool so that the series of buttons are no longer hard-coded, but created dynamically from information in the app.config file. To do this, I use a button
[Code]...
View 3 Replies
Dec 3, 2009
Why would I use an extension method instead of just creating non-extension sub or function?
For ex, I could have an extension function called IsNullOrEmptyOrAllSpaces on String, which does a check as its name implies. Or I can write a stand alone function that does the same thing. Other than having the extension show up in Intellisense, is there any advantage? Is a call to the extension quicker/more efficient than a call to a regular function?
View 8 Replies
Nov 11, 2011
I need some help on merging 2 tables. A simplified version of the issue and the error is outlined below. I am doing the following steps: 1. Create & Fill the schema of the table TblA by an adapter. TblA = DSTasks.Tables.Add("A") AdpA.FillSchema(TblA,
[Code]...
View 7 Replies
Aug 14, 2008
if they choose to use a networked version of my software, I will need the main server doing the authenticating. This is a problem, because from what I understand, it is quite easy to clone MAC addresses. I have looked into using the CPU ID and the HDD ID, but those are not unique, well at least I don't think so. Reason why I say they are not unique is because someone has the exact same CPU ID as me, and the HDD ID changes from partition to partition (same drive). Maybe the HDD ID is a partition ID instead? Anyways, I was thinking maybe I could get the Physical serial number of both the HDD and CPU, but I have not been able to find anything yet.
View 2 Replies
Feb 18, 2010
We have a network share that is used for transferring files between users on a daily basis. Every day at 3:00 am we run a vb6 program to clear the directory of this network share.
View 1 Replies
Mar 16, 2012
I saw this post and I want to know if this is possible in VB. So like extension method, do extension properties exists in VB.Net? Here I've read they do, but cannot find any examples.
View 3 Replies
Sep 16, 2010
Write an overload for every numeric type or if possible constrain a generic extension method to just numeric types.
View 2 Replies
Jul 16, 2010
Extension methods are useful for types that you don't own and can't/don't want to derive from and extend (e.g. reference types and interfaces). Obviously, interfaces should be kept as short and to-the-point as possible, so extension methods for interfaces are particularly useful (e.g. LINQ).For classes, especially classes that you own, they're still useful - but I'm wondering how you determine what should be an extension method or what should be a method in the class itself.Personally, every time I think about it, I keep going round in circles with the following thoughts:If it's useful enough, it should be in the class.It's not part of the core responsibility of the class, it should be an extension method - but if it's useful enough, surely it should be the responsibility of the class...
View 3 Replies
Jun 12, 2011
I am trying to change the background color of a tooltip
I am using tooltip.backgroundcolor = color.colr
No errors but thecolor doesn't change
View 5 Replies
Feb 2, 2011
I have an application that requires data be entered, and after entering, a button is clicked to process that data. Clicking the button works just as it should--the data is processed properly. In constructing a test module, I provide a set of data values, followed by:
btnWhatever.PerformClick()
Nothing happens. I have used this syntax for years, and it has always worked flawlessly. I have triple checked everything else and isolated the problem to the failure of the PerformClick(). The PerformClick() is in a test subroutine that does nothing but fill textboxes and labels with default data, then calls the PerformClick() on the button to begin processing. Again, the button works fine, the data is entered as it should be, but the PerformClick() does not fire the click event.
View 21 Replies
Apr 10, 2010
I know how to add extension method Like (Date.Now.MyExtensionFunction()),But I can NOT find how to add such methods and functions in class (not in module) with vb.net
View 3 Replies
Aug 11, 2009
Is it really impossible to create an extension method in C# where the instance is passed as a reference?
Heres a sample VB.NET console app:
Imports System.Runtime.CompilerServices
Module Module1
[code].....
View 3 Replies
Jan 25, 2010
I know what extension methods are, how to create and use them, but I wanted to know more about how they actually work. How do they "attach" themselves to the type of object that you are extending? Or is there even an attachment being made. I know want to know more about the inner workings, etc.. I looked around and read several different blog posts about extensions and not one of them discusses how they actually work.
View 6 Replies
Mar 26, 2012
I am trying to write extension methods in VB.NET
Imports System.Runtime.CompilerServices
Module ExtensionMethods
<Extension()> _
[code]....
But I am getting this error.Class 'System.Web.UI.WebControls.ListItem' cannot be indexed because it has no default property
What could be wrong?I am calling the code like this.
ddlSalesmanager.Items.FindByText(survey, StringComparison.CurrentCultureIgnoreCase)
P.S: I ported this wonderful code from C# to VB
View 1 Replies
Feb 23, 2012
I converted some code from c# for a VB.net project I have an object declared as this :
<Serializable()> _
Public Class oUserApplication
Public ApplicationID As Integer = 0
Public ApplicationRoleID As Integer = 0
[code]....
View 3 Replies
May 18, 2009
I ran into a strange issue over the weekend while I was working on an asp.net mvc project in vb.net. I created an extension method to convert an integer to the corresponding month it is associated with. I tested the extension method in a console application so I know it is working.
In my asp.net mvc project I have a view and want to call the extension method but I get an error that the extension method is not recognized. I imported the namespace it was contained in and still couldn't shake the error.
Extension Method:
Imports System.Runtime.CompilerServices
Module SiteExtensions
<Extension()> _
[Code].....
View 3 Replies
Nov 10, 2010
I want to implement an extension method in VB.NET that will clone an object of type T.Say, I want
Dim cust1 as New Customer() //...
Dim cust2 as New Customer() //...
cust2 = cust1.Clone()
[code]....
View 2 Replies
Jun 7, 2012
I created a module to add some Extension Methods to a Class. This Class inherits from another parent Class. In the code of my Extension Methods, I would like to refer to the base Class using MyBase. This doesn't seems to be allowed (Error message : "'MyBase' is not valid within a Module.")
[Code]...
View 1 Replies
Sep 13, 2010
I am starting to play with extension methods and i came across with this problem:In the next scenario i get a: "extension method has a type constraint that can never be satisfied"
Public Interface IKeyedObject(Of TKey As IEquatable(Of TKey))
ReadOnly Property InstanceKey() As TKey
End Interface
[Code]...
View 1 Replies
Jul 13, 2011
I'm trying to create an extension method that returns an IEqualityComparer based on a lambda function. Heres the extension method:
<Extension()>
Public Function Comparer(Of T)(Func As Func(Of T, T, Boolean)) As IEqualityComparer(Of T)
Return New GenericComparer(Of T)(Func)
End Function
[Code]...
View 1 Replies
Oct 27, 2010
I have a Direction Enum:
Public Enum Direction
Left
Right
Top
Bottom
End Enum
And Sometimes I need to get the inverse, so it seems nice to write:
SomeDirection.Inverse()
But I can't put a method on an enum! However, I can add an Extension Method (VS2008+) to it.
In VB, Extension Methods must be inside Modules. I really don't like modules that much, and I'm trying to write a (moderately) simple class that I can share in a single file to be plugged into other projects.
Modules can only reside in the file/namespace level so I have one in the bottom of the file now:
Public Class MyClass
'...'
End Class
[Code]....
It works, and "if it ain't broke, don't fix it", but I'd love to know if I'm doing it wrong and there's a better way with less boilerplate. Maybe in .NET 4?
Finally, I know I could write a structure that behaves like an enum, but that seems even more backwards.
View 2 Replies
Nov 16, 2011
I've created a MyFunc extension (in Module Extensions) for all the base types as well as generic arrays, ICollection(Of T) and Dictionary(Of String,T):
Function MyFunc(Of T)(a() As T) As String
Function MyFunc(Of T)(collection As ICollection(Of T)) As String
Function MyFunc(Of T)(dict As Dictionary(Of String,T)) As String
[code].....
View 1 Replies
Jan 1, 2010
how do we access MyBase from an extension method?
i'm trying to extend a Sub called PassDown that would call the form's Base's OnPaint method
<Runtime.CompilerServices.Extension()> Public Sub PassDown(ByVal form_instance As Windows.Forms.Form, ByVal e As EventArgs)
MyBase.OnPaint(e)
but of course, mybase couldn't be accessed this way so is there an alternative?
View 5 Replies
May 31, 2012
Can I access values in application settings of web.config in extension method?I have the below code but it is not working:
<Extension()> _
Public Function DocCountExt(ByVal value As Collection) As Integer
Dim maxOffSet As Integer = Integer.Parse(ConfigurationManager.AppSettings(APP_SETTINGS_OFFSET))
return maxOffSet
End Function
The above code does not work.
View 3 Replies