Optional 'Color' Variable Parameters In Classes?

May 27, 2010

Is it possible to make Color variable parameters in custom classes Optional?Everytime I try, it gives me a "Constant expression required" error.[code]

View 2 Replies


ADVERTISEMENT

.net - Utilize Optional Parameters In Delegates?

Aug 6, 2010

However, I am wondering if there are any workarounds or plans for incorporating this feature into VB.NET in the future?What I'd like to do:

Public Delegate Function Deserializer(Of T)(ByRef Buffer() As Byte, optional ByRef BufferPosition As Integer = 0) As T
'Implementation of a func that matches the delegate'
Class A
Public Function Deserialize(Byref Buffer() as Byte, optional Byref BufferPosition as integer = 0)
....

In the absence of specifying "optional" inside the actual delegate itself, it'd at least be nice to be able to do it in the function implementation only:

Public Delegate Function Deserializer(Of T)(ByRef Buffer() As Byte, ByRef BufferPosition As Integer) As T
'Implementation of a func that matches the delegate'
Class A
Public Function Deserialize(Byref Buffer() as Byte, optional Byref BufferPosition as integer = 0)
....

At least this second way, the functions for the delegate will always have a value mapped to each parameter, although some may come from the function side and not the calling side.

View 2 Replies

Asp.net 1.1 - Assign Null Value To Optional Parameters In .NET 1.1?

Dec 21, 2010

I tried DbNull.Value but no luck. How do I assign a default value as null to a string parameter that is null in VB.NET? Its litte strange to see that VB does not have anything like plain null as most of the other languages do. Also what is the difference between null and DbNull and Nothing.

View 3 Replies

C# - Handling Optional .NET DataSource Parameters?

Aug 9, 2011

What is the standard way to implement optional query parameters in a .NET WinForms application?In other words, only query on a field if the value of a corresponding control is not null.

EDIT: I use a FillBy method which calls a query in my Access database. In the TableAdapter query editor, I just used WHERE (field1 = ?) AND (field2 = ?) ... I just can't find the "hook" to bind form controls to the table adapter query parameters and so that if a form uses the default value to not query on it.

View 2 Replies

Error : Optional Parameters Must Specify A Default Value

Jan 21, 2011

Public Function Foo(ByRef a As AClass, _
Optional ByRef b As BClass = Nothing, _
Optional ByRef c As CClass = Nothing) As XClass

Error : Optional parameters must specify a default value.

View 2 Replies

Optional Parameters Cannot Have Structure Types?

Jan 12, 2010

I would just like to know why. optional parameters cannot have structure types?

View 4 Replies

Calling A Vb Function With Optional Parameters With A C# Call?

Nov 3, 2010

I am interacting with VB code on a different tier, using a client-side c# program. The VB function signature looks like this:

Public Sub toggleExclusion( _
ByVal mouse As Double, _
ByVal study As Integer, _

[Code]....

I get an error saying no overloaded method of toggleExclusion takes 2 arguments?

View 3 Replies

Databind To Object Parameter That Has One Or More Optional Parameters?

Mar 22, 2011

I have an object, called 'PERSON' This person object has a title, firstName & Surname property as well as many other which are at the moment irrelevant. It also has a read only property called Fullname which concatenates the two or three parameters mentioned above depending on an optional parameter 'withTitles' passed over when you call PERSON.FULLNAME

PERSON.FULLNAME(true) <- Will add titles if there are any

PERSON.FULLNAME(false) <- Will give the name without the title

Public ReadOnly Property FullName(Optional ByVal withTitle As Boolean = False) As String

[Code]...

I get an error: PERSON does not contain a property of 'FullName'. If I change this to any other property that does not take a parameter it works as expected. Now I'm guessing that the binding procedure can't handle optional or mandatory parameters for object properties, is this right? Is there a better way to do it? I thought about looping through the collection to add them manually but that kinda defeats the object of DataBinding!

View 1 Replies

Java: Switch Statements & Optional Parameters?

Apr 27, 2011

Is there an equivalent in Java to VB.NET's optional parameters?Also is it possible to switch on anything other than integers in Java?

View 1 Replies

Optional Parameters Versus Method Overloads?

Oct 6, 2009

I was familiar with the optional parameters in vb 6 and it made sense given the capabilities of the language but why the heck does VB.Net support optional parameters when there is method overloading? Which one should I use and is there a difference? If there is a difference when should I use each one?

View 4 Replies

VS 2010 Optional And Named Parameters In An Attribute?

Sep 7, 2010

I have a custom Attribute class where the constructor takes one fixed parameter and two optional parameters. It is my understanding that one can supply one or more optional parameters by using 'named parameters' such as this:

Private Sub CallMethod()
Me.OptionalMethod(-1, z:=1)
End Sub

[code]....

Well, I thought, perhaps Attributes don't support named parameters. I know they can behave a little weird (they don't support all types in their arguments for example I think), so I thought little of it.But then... I noticed something else. If you take a look at my code of the attribute class again. Notice that I am using an attribute on that class as well... And what do you know: named parameters. Working just fine... The AttributeUsage attribute has the exact same configuration: one fixed parameter and two optional parameters. I seem to be able to call them using named parameters just fine, where I cannot call my own attribute constructor with named parameters...

View 3 Replies

.net - Inheriting A VB Class In C# And Overriding Constructors That Take Optional Parameters?

Jan 12, 2010

Most of our code base is in VB.NET. I'm developing a project in C# that uses a lot of the assemblies from the VB.NET code.There are three relevant classes in VB.NET:

[Code]...

View 3 Replies

Sql Server - Optional SQL Parameters For Binary File UPSERT

Sep 16, 2010

I'm using a stored procedure to updateinsert data into a table using MERGE. One of the items being inserted is a VarBinary file. Now if I wish to add a new file it's just a case of using ReadAllBytes as below, to remove the file I pass DBNull. Now what if other fields are being updated but the file is not being changed? I want the field to remain untouched unless I'm replacing the file or deleting it as above. I cannot add the file via the parameter again as it may only exist in the database, unless I read it first and write it back which seems pointless. [Code]

View 1 Replies

Asp.net - Building A Valid SQL Query With Optional Parameters For Search Function?

Oct 20, 2011

I have a search function de build.We are using pure ASP.NET w VB.NET We have multiple DropDownLists and we're building a search query with whatever was selected in those DDLs. My question is, how can I handle the blank values (unselected dropdownlist values) with the SQL Query ? I'm using AND operators in the query so if anything is blank it'll fail the search. If the dropdownlist has no selected value, i don't want the value to be part of the search. It would be easy to code with just 2-3 parameters, but we're looking thru at least 10 items and doing a SWITCH CASE or multiple IFs would soon become mayhem.

View 1 Replies

Using Color As Optional Parameter In A Sub/function?

Nov 3, 2010

how can use color as an optional parameter in a sub/function?This doesn't work.

Code:
Public Sub WriteLog(ByVal sText As String, Optional ByVal lColor As Color = Color.Blue)
'Code
End Sub

View 5 Replies

Vb6 Declaring Functions - Error - "optional Parameters Must Specify A Default Value"

Oct 19, 2011

I just got upgraded from VB6.0 to VB2010. I'm trying to move some of my program functions over and I'm getting an error on the ones where I use optional... Public Function GetFolder(ByRef FTT As String, Optional InitFile As String)

I get the error at the end of the line, after the close par...the error is "optional parameters must specify a default value".

View 3 Replies

Pass An Optional Parameter To A Function Of Type System.Drawing.Color - Error "Constant Expression Is Required"

Mar 22, 2012

I want to pass an optional parameter to a function of type System.Drawing.Color. The problem I am having is that when I declare the function it says "Constant expression is required" but I have tried variations of the following, including integers, full qualified indentifiers, even old vbWhite constants to no avail.

[Code]...

View 14 Replies

VS 2010 Using Variable In Different Classes?

Oct 21, 2010

Public Class Form1 Dim CharList As ArrayList Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click CharList.Add(TextBox1.Text.ToUpper)End Sub Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click

[Code]...

View 2 Replies

VS 2010 Variable Scope In Nested Classes?

Jul 13, 2011

I have put together the following code to illustrate the problems I've been struggling with:

Public Class OuterClass
Private _OuterProp1 As Boolean = False
Public Property OuterProp1 As Boolean

[code]....

I need to be able to refer to outer class properties and variables in an inner class, and I need to have a variable in one inner class set in a different class. I've tried Public, Private, Protected, Friend and all kinds of combinations of them, and I can't figure it out.

View 4 Replies

Accept A Variable Number Of Parameters?

May 26, 2009

I am trying to design a Function/Sub that will need to accept a variable number of parameters. Catch is that the parameters being passed are arrays themselves. As i understand it when you pass a variable number of arguments to a method, you pass them via an array. What im looking for is to make a method that would accept this form:

[Code]...

View 6 Replies

Use IN Operator With Variable Number Of Parameters?

Mar 11, 2012

I have a dataset connection to an MS Access database. I want to use IN operator in WHERE clause like: WHERE DepartmentID IN (1,2,3)This means that all record with an ID of 1, 2 and 3 will be filtered. But the problem is I cannot create a parameter like:

[Code]...

View 1 Replies

Variable Number Of Parameters In Query?

Jun 11, 2012

I want to query items from countries that are selected from a treeview (with checkboxes). However the number of countries that is selected by the user is not known beforehand. So how can I make a proper query when the number of OR operators is unknown? For example: SELECT DISTINCT Item FROM Countries WHERE Country LIKE @c1 OR @c2 OR @c3 etc� and then add the parameter values based on the selected countries in the treeview. I looked into parameter arrays but can�t make sense out of it really

View 13 Replies

Declare A Variable To Be Shared By 2 Forms (classes) In The Same Project?

Jan 1, 2011

I've gone brain dead and can't remember how (where) to declare a variable to be shared by 2 forms (classes) in the same project.

View 2 Replies

Script Task: Write 2 Classes And Access Global Variable

Mar 18, 2012

Can i write 2 classes for one Script Task editor in SSIS(2008). I tried to access the global variable like below. I created 2 classes and it doesn't show any compile error, but i couldn't access the global variable in class2 which was assigned as 2 in class, ScriptMain.

[Code]...

View 1 Replies

What Are The Conventions For Variable Naming In .NET To Avoid Confusion Between Parameters And Properties

Oct 21, 2010

In the example below, what would you name the parameter given that it is used to initialize the property FromDate?For class constructor methods, I like to have the name of the constructor parameter variable match the name of the property which is being initialized. For example, the parameter "fromDate" is used to initialize the module level variable "_FromDate" with the statement _FromDate = fromDate. Likewise, I could have alternatively written Me.FromDate = fromDate.

Proponents of C#'s case sensitivity would probably say that using a leading lower cased letter for the param variable name, which I believe is MS convention, is an acceptable approach to distinguish it from the Property of the same name but different casing.

However, VB is not case sensitive, which I generally appreciate. In the following example, I am using a param name that matches the property name, 'fromDate," and VB refers to the local instance when there is ambiguity. However, many would probably argue that this "ambiguity" introduces the opportunity for the developer to get confused and not realize which variable is being used. For example, my intent below was to have TWO params passed in, "fromDate" and "toDate" but I accidentily ommited one and as a result, the VB.NET did not warn me of the mistake because it assumed that the statement _ToDate = ToDate was equivalent to _ToDate = Me.ToDate instead of informing me that the variable on the right side of the assignment statement was undeclared.

Public Class Period
Property FromDate As Date
Property ToDate As Date

[code]....

In my judgement, we should have a convention for prefixing all parameter variable with a prefix, but hasn't the use of prefixes been discouraged by Microsoft? For example:

Public Sub New(ByVal paramFromDate As Date, paramToDate As Date)

..or maybe it could be shortened to pFromDate, pToDate...

View 3 Replies

Optional Date Value In One Of My Sub - Handle The Default Value For An Optional Date?

Mar 6, 2010

I am trying to have an optional Date value in one of my sub but since you cant set Date to nothing, this doesn't work. And i cant set it to the Date.minvalue inline.

Private Sub abc (ByVal A As String, Optional ByVal B As Date = Nothing)
End Sub

So, i went and set it to some date in the past.

Private Sub abc (ByVal A As String, Optional ByVal B As Date = #1/1/2001#)
End Sub

what would be the proper way to handle the default value for an optional Date?

View 3 Replies

VS 2008 Variable Color?

Dec 2, 2010

I have seen some code in the internet where the variables are differentiated with another color. It seems to help a lot with reading the code faster. Where in the options menu (if any) can I turn the color for the variables on please?

View 3 Replies

IDE :: Screenshot Shows Different Color Of Same Variable?

Oct 17, 2011

Screenshot shows different color of same variable. AsFile - extension method.There is no knowledge that is not power.

View 4 Replies

Change Color Of An Object By Setting Variable

Aug 1, 2010

I need to change the color of an oval on the user interface form based on a variable being true or faulse.

View 10 Replies

Change Back Color Of A Label By Command Button By Using A String Variable ?

May 29, 2012

i tried to change back color of a label by command button by using a variable value

Private Sub Button3_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim colorof As String
colorof = "Color.Red"[code]....

but its giving error and is not working,

Label1.BackColor = Color.Red is working but I wanted to do this with variable value

View 35 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved