.Net- Avoid Closures When Defining Lambda Functions?
May 17, 2012In vb.net, this is serializable:
<Serializable()>
Class FunctionHolder
Private _F As Func(Of Double, Double)
[code].....
In vb.net, this is serializable:
<Serializable()>
Class FunctionHolder
Private _F As Func(Of Double, Double)
[code].....
i am comfortable with class, namespace ,Sub ,Function ,Properties ...and so on. i studied about Custom Controls and Extension methods. There i found something new so called Attribute that are placed before classes and Functions definitions.[code...]
View 4 RepliesWhat is the best way to write functions in Microsoft.NET (VB) to avoid memory leaks. I have always followed this style:
Public Sub TestMemoryLeak()
Dim testCon As SqlConnection
Try
[code].....
Here the connection reference is created before the TRY clause and is initialised after the TRY clause. I believe the connection is always closed and dereferenced even if an exception is thrown. Is this good practice? I see a lot of code that creates references and dereferences in the TRY clause, but this would mean that the memory is not correctly handled if an exception is thrown. Some developers say they don't like to clean up in the finally clause.
Im hearing about this, can someone explain it to me or please show some basic code of Lambda with explanation.
View 2 RepliesIs it possible to shorten the following function to a lambda expression?Or (to do the trick by myself) what is the best and most understandable for beginners tutorial for lambda in vb.net?[code]
View 2 RepliesWhat I am trying to do is have a class where the functions of the same name are both instance functions and shared functions.
Public Shared Function Get...(byval xx as xx)
and
Public Function Get...
The Public Function uses a Property xx created in the constructor, whereas the Shared Function has the parameters (byval xx as xx).
1) Is it possible to access the Excel mathematical functions without actually opening Excel?
I was thinking of through a DLL WinAPI call or maybe a delegate function or smaller program?
2) Does anyone know of a MS link or area that gives instruction on "how to" use every function of every Windows DLL at all?
Or for all those that Microsoft have chosen to document online at least.
While converting types, I have found myself using both VB functions and BCL Convert.To* methods.
E.g.)
Cstr() vs. Convert.ToString()
CInt() vs. Convert.ToInt32()
CDbl() vs. Convert.ToInt64()
etc...
Are there any subtle differences that should be noted?
Is there a way to see exactly what the functions are doing. What i mean is there a way to see the class? I know what it does, i just want to know the code.
For example the function: Membership.FindUsersByName()
Am I just limited to the VB pen colors, e.g color.orange, color.black etc or can I define my own rgb colors? If so, how do I do that?
View 4 RepliesI have .cls files that have attributes for XML files, and i would like to refer to them in the main body of my code without having to define each one as a class in the code as this would be writing them twice. How can i refer to a .cls file in a vb.net form? If you're not living on the edge, you're taking up too much room
View 5 RepliesI would like to define an interface in the same manner as IDispose. By this I mean that when the interface is implemented it would add functional code.
For example when IDispose is implemented it adds a fully defined Dispose method rather than just an empty sub routine.
What would the folowing VB.NET enum definition look like in C#? [code]
View 7 RepliesHow do I define the controls from another class? Here is my code (highlighted) -
Imports System.Windows.Forms
Namespace Bryanlgh.Echo.Views
Namespace Bryanlgh.Core.Tasks
[Code]....
I also tried using Imports Bryanlgh.Echo.Views instead of Namespace and it also came up with 3 error messages -
1. Namespace or type specified in the Imports ' Bryanlgh.Echo.Views' doesn�t contain a public member or cannot be found.
2. Name 'cboPcpMd is not declared.
3. Name 'cboPhysicianPerforming' is not declared
How should I define these controls?
I have a dropdown where the items initially are filtered (using a SQL Datasource) based on the selection of another dropdown; however, I have included a checkbox where if checked, the dropdown needs to populate with all data from another datasource How do I programatically remove a datasource that is bound to a control and then define another?
I have the following code, but it errors:
If cbOverrideArea.Checked Then
Me.ddArea.Items.Clear()
[code].....
I am using Excel interop in my VB.NET program. My problem is that I can't seem to figure out how to write to Excel *and* define the Range using numbers.Alright, so I have objects being created depending on the file that the user opens. So there could be 100 objects or there could be none. Now each object has an array of values, and these arrays contain nearly 15000 elements. So here is what I want to do but I can't figure out how to escape using the LetterNumber:LetterNumber combination.
For every object I want a new column to be occupied and for every element in the objects array I want the row to be occupied. I figured the easiest way to do this was using a for loop but, again, I can't use numbers.
For columns = 0 to NumberOfObjects
For rows = 0 to NumberInArray
Cell(0,0).Value = myObjectsCollection(column).Array(rows)
Next
Next
I am using Excel interop in my VB.NET program. My problem is that I can't seem to figure out how to write to Excel and define the Range using numbers.
Alright, so I have objects being created depending on the file that the user opens. So there could be 100 objects or there could be none. Now each object has an array of values, and these arrays contain nearly 15000 elements. So here is what I want to do but I can't figure out how to escape using the LetterNumber:LetterNumber combination.
For every object I want a new column to be occupied and for every element in the objects array I want the row to be occupied. I figured the easiest way to do this was using a for loop but, again, I can't use numbers.
For columns = 0 to NumberOfObjects
For rows = 0 to NumberInArray
Cell(rows , columns).Value = myObjectsCollection(column).Array(rows)
Next
Next
How do we create relation ships between tables using a sql query?im using MS Access and VB.net.
View 2 RepliesI used to do this is VB6:
Type Record
A As Long
B As String
End Type
Dim Rec As Record
When I keyed in "Type" in my declarations, I was asked to change it to "Structure". After that, I was not able to define anything inside. So, what do I need to do?
I have to define a name for a varying-length column of cells. The name is used later to define the range for a Data Validation List. I just cannot figure out (and the Help Function isn't assisting) how to define the Name, say "DropOrdNum" using a variable as the address for the last cell in the range. It is easy to define a name for "O13:O2000" - no problem, but then I have a whole lot of blanks in my drop-down list. But how do I define a name for "O13:LastCell", by making "LastCell" the Range Variable (am I correct in this) for the address of the last cell in the active range and then defining the name "DropOrdNum" as being the range "O13" to either "O(the row number of the last cell)" or "LastCell", being the address of the last cell in the active range, which varies by the hour?
View 2 RepliesI know you can dimention a variable and assign data to it at the same time using dim a() [1,2,3,4,5,6,7}but how can you do this with multiple arrays.is it something like [code]
View 4 RepliesIn C# you can use the implicit keyword to define an implicit user-defined type conversion operator.In VB.NET you can define a CType conversion operator that will explicitly convert a user-defined type into another type.Is there a way to declare an implicit conversion operator in VB.NET?
View 1 RepliesIs it possible to define two variables in a vb2005 For loop in a similar way that jscript does it?
the javascript example is
for(i=0,l=0;i<20;i++){}
The below sub-procedure isn't working like I expect it to. Basically, I have 9 fields on a tab control. When a user clicks in one of the fields, I wish for the field to "SelectAll" if their is a value already in the field. As you can see, the way I have it structured...only 1 field will do this, however, even this is not working.
Private Sub txtAddr1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAddr1.Click, txtAddr2.Click, _
txtAddr3.Click, txtCity.Click, _
cmbState.Click, txtZip.Click, _
[code]....
I've got a bunch of duplicate code that looks like this:If mValue is Nothing Return ""Return mValue.ToUpper
I defined the following extension method to reduce duplicate code:
[Code]...
How can I use a MembershipProvider in a Winforms application without defining ConnectionStrings, Membership and RoleManager sections in app.config but creating instead all needed objects and configuration settings at runtime?
View 1 RepliesSo my latest project focuses on sending txt commands over from my cell phone to my email, which gets read by a program, that carries out the specified command. My latest command i want to implement, is being able to define words, and have it send me a txt back with the definition. Now I know how to send texts, and all of that stuff, but I have found it hard to find anything on defining words. At first, i tried to read websites, and simple redirect a webpage to google definitions, but that led me nowhere.
View 1 RepliesI am trying to create a property and declare it as a dictionary. This property will be updated and called upon throughout my project. I may be complicating the issue but here is what I have...
vb.net
Private Shared m_ItemName As Dictionary(Of Integer, String)
Public Shared Property ItemName(ByVal Tkey As Integer, Tvalue As String) As Dictionary(Of Integer, String)
Get
[code]....
What I wish to do with the dictionary is to keep a record of the amount of items selected, the Key will be the Integer in the dictionary and will be the ID of that item in a database while the String will be the name of the item matched to that ID in the database.The user will be allowed to enter up to no more than 10 items at a time (overkill but necessary for the unknown).I was originally going to use an array statically declared allowing up to 10 items (eg. Private Shared m_ItemName(,) As String = New String(9,9) {})
I have connected my sql db with vb and I m trying to make a UI. My question is that when I write code in order to create datatables and I fill them with the results of queries I've created, where do these datatables belong? I'm wondering if I have to define a new dataset or do they belong to the existed dataset which is created by the dataset configuration wizard??
View 3 RepliesHow do I limit an Interface when defining it? What is the correct technical term for what I am describing?For example, I want MyInterface to only be implemented for objects that implement IList(Of T) and ICollection(Of T).
View 5 Replies