VS 2008 Nullable Property Question?

Feb 16, 2011

I have Nullable properties in my class:Public Property FileStatusID() As Integer?

Get
Return m_FileStatusID
End Get

[code].....

View 7 Replies


ADVERTISEMENT

Property Keycode Is Non-nullable?

Apr 7, 2009

I am creating a setup project for my VB application. Everything seems to look fine. However when I tell it to build the solution I get the following error:Property 'keycode' is non-nullable. I have never seen this before in other setup projects and I can't find any help from MS.

View 8 Replies

Use Nullable(of T) For Property Using List<of T>?

Jan 17, 2012

In the below sample code, I have tried to use Nullable(of T) for DateTime and I want to use it same of the Dimensions property which is List(of Dimension).

CODE:

View 1 Replies

Nullable(Of Double) Property Turns Nothing Into 0.0?

Mar 5, 2009

I was under the impression that any time I set a Nullable(Of Something) to Nothing, it will take the value of Nothing.In a class, I have;

Private _something As Nullable(Of Double)
Public Property Something() As Nullable(Of Double)
Get
Return _something
End Get

[Code]...

In my page, using this class I set Something = Nothing, but as I step into the Set method, value = 0.0.Am I doing something wrong here? Or do I just not understand Nullable types yet?

View 4 Replies

Build Error - Property Keycode Is Non Nullable

Jul 4, 2005

I tried to build my project but it has 1 build error
:Property 'Keycode' is non-nullable.
I double click it but it points nowhere. I'm really desperate. My project consists of Crystal Report. It had just been upgraded from version 8.5 to version 11. Is it possible that this is the source of error?

View 5 Replies

Invoke HasValue On A Nullable Property Of An Object Via Reflection?

Sep 15, 2010

This function loops all properties of an object to create the updatequery to save te object to the DB.

We had to make some changes to it because of the introduction of nullable properties. If the property is nullable we would like to check the 'HasValue' property. This does works when it has a value. When the property has no value we get an 'Non-static method requires a target'-error at the CBool-line

An other way to check the 'HasValue'-prop of a property using reflection?

Private Function GetUpdateQuery(ByVal obj As Object, ByRef params As List(Of SqlParameter), Optional ByVal excl As String() = Nothing) As String
Dim sql As String = String.Empty

[Code].....

View 1 Replies

Nullable Property - Set Code That Execute In The Case Of The Value Being Null

Sep 17, 2010

[Code] Now the problem is that after i put this user-control in a form, I have to set a value for the Handled file. Otherwise it gives me a value cannot be null exception. Is there a way that i can set code that would execute in the case of the value being null? [Code]

View 14 Replies

Set Nullable Property In Program Like "public Decimal?

Dec 17, 2011

How to set Nullable Property in vb.net like "public decimal? unitprice {get; set;}"

View 2 Replies

Why Won't A Nullable Public Property In A Class Accept 0 (zero) As Assignment

Apr 17, 2009

I have a nullable public property on a class using Vb.net 3.5:

Public Property TicketCharge() As Nullable(Of Decimal)
Get
If _TicketCharge = Nothing Then

[code]....

View 4 Replies

.net - CLR FormatException Thrown When Databinding An Int32 Field To A Nullable Decimal Property?

May 28, 2012

I have written a .Net 4.0 Winforms Numeric Editor control (which inherits from TextBox), and I have added a Value property that is a nullable decimal type, as follows:

Public Class NumericEditor
Inherits TextBox
Private _value As Decimal? = Nothing

[code]....

how to get around this exception, particularly when I'm databinding a number field to a number property, and there should be no string conversion happening. (To further complicate things, I'm using a similar technique for another control where I databind a DateTime field to a nullable DateTime property, and that control works just fine.)

View 1 Replies

VS 2008 Nullable Object Must Have A Value?

May 20, 2009

I am getting an unusual error "Nullable object must have a value" when running the code below.

[Code].....

Interestingly the Stored proc used by the table adapter still runs and does the insert but the function returns the error.

View 8 Replies

VS 2008 - Nullable Datatype Inhibits Formatting?

Nov 29, 2010

[Code]...

When x is nullable I get an error 'Overload resolution failed because no accessible ToString accepts this number of arguments'. I suppose I could copy the nullable variable into a non-nullable variable, then format it, but that seems extremely clumsy for something that should be fairly simply. Isn't there a better way?

Arghh! Copying the Date? variable into a Date variable doesn't work-Option Strict is On & that sees the two variables as being of different types. Is it really necessary to to an explicit CDate conversion on a nullable date variable?

[Code]...

View 1 Replies

VS 2008 BLL - Nullable Types And Crystal Reports .Net

Jul 21, 2011

I'm using my data objects in a crystal report. The thing is, when I select my object, it gets added to the field explorer table. My properties are listed except for the Nullable Type properties. Why would this happen. I've had quite a few issues yesterday as this is my first attempt at a crystal report in .Net. I thought I worked around them but now I've hit this snag.

View 11 Replies

Nullable Object Must Have A Value Inserting Into An SQL Table Using VB In Visual Studio 2008?

Dec 6, 2009

I have an insert query set up for my VB table adapter. It includes all the columns in my table. Some of these columns are Nullable VARCHAR and DATE and I want to set them to null on the insert.

In my code I have two varaibles defined as Dim Sdate as nullable (of date) Dim Sdata as nullable (of Char)

And I set them as follows:

Sdate = nothing
Sdata = nothing

On the insert query the "Catch" is activated and displays "Nullable Object must have a value"

I Sdate and Sdata have values, then the insert works just fine.

View 9 Replies

VS 2008 Webservice Compilation Error Re:System.Nullable(Of Decimal)

Jun 1, 2009

Quote:Value of type System.Nullable(Of Decimal) cannot be converted to System I have the code below which seems to work fine on my development server but causes a compilation error when I put it on my live webserver (uncommented).The error message I get from the event viewer in IIS is as above.

' <WebMethod(Description:="Insert into Referral Payments Table.")> _
'Public Function InsertReferralPayment(ByVal ReffererCustID As Integer, ByVal InstalledCustID As Integer, ByVal AmountReferrer As Nullable(Of Decimal), ByVal AmountInstalled As Nullable(Of Decimal), ByVal ReferrerChequeSentDate As Nullable(Of Date), ByVal InstalledChequeSentDate As Nullable(Of Date), ByVal ReferrerChequeNo As Integer, ByVal InstalledChequeNo As Integer, ByVal InputBy As String) As Integer

[code]....

From what I can tell IIS is configured the same and both referenced DataTables seem identical.

View 7 Replies

VS 2008 - Property Grid - Click On Item Show Its Property

Mar 18, 2009

I have a listbox with several list items added. I want that as user click on an item, I should be able to show its property. This should change for different items. For example (hypothetical) : Listbox has numbers 1 - 10. Now when I select 1 I should be able to set property - Name, Lastname, Colour, Age.

When I select 2 I should be able to set - Age, Hair Colour (clr shows), Weight, Date. When I select 3 then - City (combo box drop down), Country, Age only. This way value changes for diff items. One way is to put them in property grid and show them. Though this looks nice but adding/removing items in that is not easy. You need to have a class that refer that to prop grid. Do I have to code for each classes for all values in listbox or is there an easier way to manage items in property grid. If you think prop grid is not the right tool for such an activity then can you suggest something else.

View 13 Replies

Pass A Nullable Valuetype Into A Non Nullable Valuetype?

Sep 17, 2009

I accidently wrote some code today that was like this[code]...

I immediately noticed the issue, but I had already hit the run button. It compiled successfully, I ran it through to the section and it threw an exception.

You can't do this in C#, it gives a compile error "cannot convert from 'int?' to 'int'".

Is there an 'Option Explicit' type switch that I can turn on to ensure that this sort of error does not occur again?

View 1 Replies

.net - 'Property' Cannot Implement 'Property' Because There Is No Matching Property On Interface 'IName'?

Dec 9, 2011

I'm having some very weird issues with interfaces right now.

I have a very simple setup. In one of my class, I have a Property implementing a Property from an Interface.

In my class it's like:

Private _oForm As IForm
Public Property Form As IForm Implements IContainer.Form
Set(value As IForm)

[Code]...

I have like dozens of interfaces like this working throughout my project and I can't believe this simple one can't work!

View 1 Replies

.net - Nullable Object Must Have A Value Vb?

Dec 5, 2011

I have a bigger code block which I have recreated in this simpler example:

[Code]...

View 1 Replies

Add Together Two Nullable Types?

Aug 27, 2010

I have: Dim nVar1 As Long?Dim nVar2 As Long?Dim nVarSum As Long?nVar1 = Nothing nVar2 = 5 nVarSum = nVar1 + nVar2 I would prefer the result to end with nVarSum being 5, instead of Nothing. I understand if you add something to an unknown value, you will end up with "somthing + unknown" or x+5 will always equal "x+5" not "5" because you are still carrying around that unknown "x". However, how can I effectively treat an unknown or Nothing as a zero for the purposes of addition in this case?(What is basically happening is that the end user is sending us a data file, this code parses that file and then sums together about 15 fields. If the user leaves those fields blank instead of assigning a zero to them, I need to treat it as if it was a zero for this one addition operation, but all the rest of the code needs to continue seeing it as a Nothing value since the user did not ACTUALLY submit zero... they submitted blank or nothing)

View 3 Replies

Can Nullable Types Be Used

Jun 27, 2012

Can Nullable Types be used in VB.NET? If so, is it possible to have a Nullable Integer that I can use with a field that accepts NULL in SQL Server?

View 4 Replies

How To Use Nullable Types

Aug 25, 2010

I'm converting an Access VBA app to VB.NET. It has dates defined as variants or objects to handle null values. I thought this would be a great chance to use the Nullable type. But I can't get it to work. Either it is inappropriate for what I am trying to use it for, or I am doing it wrong. Anyone know how to use it? Reader is a SqlDataReader.

[Code]...

I was hoping I didn't have to put a lot of If .. Null statements throughtout the code, but that is my only option unless someone has any other idea.

View 11 Replies

Nullable - What Does DataType Mean In .NET

Sep 15, 2011

I have the following line of code:

CType(IIf(CBool(product.IsDiscontinued Is Nothing Or product.IsDiscontinued = True), False, True), Boolean?)

What does the Boolean? mean at the end. I have seen it used on other data types as well.

View 3 Replies

Nullable DateTimePicker?

May 6, 2009

I have a Nullable DateTimePicker but it lacks a vital property, that is to be able to change its ForeColor, anyone who has some suggestion on how can this be done? Or perhaps a free nullable DateTimePicker out there that supports changing of backcolor and forecolor?This is C# but it should not be different with .Net, and I prefer posting it here since there is more traffic here over the C# section.

using System;
using System.Collections.Generic;
using System.ComponentModel;[code].....

View 2 Replies

Nullable Object Must Have A Value

Jan 31, 2012

Okay, none of the previous questions I have seen with this error seem to apply in this situation.tEmp is a class that contains (among other things) two nullable date fields.[code]During a routine on my form, I am attempting to see if the following conditions are true[code]I get the above error (the title of question), but when I hover over the debugger, NextReview and InsuranceEligibleDate are both Nothing (which is correct for the employee I am looking at).I am using VB2010, and the Properties in the Employee class are using the new way of declaring Properties (i.e. no set/get)

View 4 Replies

.NET: Why Doesn't This Nullable Work

Dec 15, 2010

dim str as nullable(of string) is this syntax incorrect?

View 1 Replies

C# 'AS' Equivalent For Nullable Types

Feb 15, 2011

C#'s 'as' keyword will let you do this: int? input = value as int? Here's what I would assume the vb.net equivalent would be: Dim input As Integer? = TryCast(value, Integer?) There's an intellisense error in the TryCast stating the operand must be a reference type but Integer? is a value type.

Intellisense on Nullable(Of Integer) says 'Represents an object whose underlying type is a value type that can also be assigned null like a reference type.' It seems C#'s 'as' handles this like a reference type where TryCast doesn't have this built in. In VB10 I was able to take advantage of the new CTypeDynamic function to do the casting. Conversion.CTypeDynamic Method

Dim input As Integer? = CTypeDynamic(Of Integer?)(value)

Or:

Dim input As Integer? = CTypeDynamic(Value, GetType(Integer?))

There's a cost here as CTypeDynamic examines the type at runtime.

My question is what is the elegant way to handle this without CTypeDynamic?

View 6 Replies

C# 'AS' Equivalent For Nullable Types?

Nov 15, 2011

Dim input As Integer? = TryCast(value, Integer?)There's an intellisense error in the TryCast stating the operand must be a reference type but Integer? is a value type.Intellisense on Nullable(Of Integer) says 'Represents an object whose underlying type is a value type that can also be assigned null like a reference type.'It seems C#'s 'as' handles this like a reference type where TryCast doesn't have this built in.

View 1 Replies

C# - Comparing The Nullable DateTime's?

Nov 17, 2010

I am a c#/asp.net developer and I am having to work on a VB/asp.net. I have two variables

Dim originalDate as DateTime?
Dim newDate as DateTime?

Both nullable datetimes, originalDate is a nullable date I am getting from the database and newDate time is set in code, I need to compare them, they can either both have dates, neither have dates or one have and one not.

I have a bit of code as follows:

if origEndDate = origEndDate then

When both origEndDate and origEndDate are "nothing" this statement is false (well when I run it in the watch window it comes back as nothing)!I don't understand why this is the case because I was under the impression doing an "=" compares the two values and as they are the same surely it should be true? What syntax should I be using as in C# I can do the above as so:

if (origEndDate == origEndDate) { }

and it will come back as true.

View 4 Replies

C# - Correct Way To Check If Nullable Has A Value?

May 8, 2011

assuming v is a nullable, I'm wondering what are the implications / differences between these usages:

VB:

If v Is Nothing Then
If v.HasValue Then

C#:

if (v == null)
if (!v.HasValue)

View 4 Replies







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