We had a Nullable object must have a value error today on this line of code:list = From x In Me Where x.FooDate.HasValue AndAlso x.FooDate.Value.Date >= barDate
Funny thing is that I feel sure this used to work fine (and there has always been a sprinkling of null values in the underlying data). And logically it looks fine to me. The check for HasValue and the AndAlso look as if they're going to shield us from any Null danger.But it seems suddenly they're not. Am I missing something?OK, we can correct it to this, which eliminates the error:
list = From x In Me Where If(x.FooDate.HasValue, x.FooDate.Value.Date >= barDate,False)
But this looks to me less readable. In simplifying the above code to shorten the line I left out a crucial chunk of the code. The original problem should have read something like:
list = From x In Me Where x.FooDate.HasValue AndAlso x.FooDate.Value.Date >= fromDate And x.FooDate.Value.Date <= toDate
Because of the rules of shortcircuiting and operator precedence (as outlined in an answer to a long ago question of my own) I needed to add brackets round the second part of the instruction in order to stop LINQ evaluating the second x.FooDate.Value.Date:
list = From x In Me Where x.FooDate.HasValue AndAlso (x.FooDate.Value.Date >= fromDate and x.FooDate.Value.Date <= toDate) LINQ really does obey AndAlso and force me to look more closely at the original problem.
How can i return null values in if statement above. This statement is not working if condtion is false its retruning me 0 value even if condition is false
dim d as nullable(0f Decimal) d=(if(_dr("value") isnot dbnull.value,Convert.toDecimal((_dr("value")),Nothing)
I'm maintaining a set of code that has a wrapper class for SqlDataAdapter to load a System.Data.DataTable. It has a generic function to determine if the DataTable "hasRecords". I know it's a minor issue, but out of curiosity... Which is the faster method to use?
Existing:
Public ReadOnly Property hasRecords() As Boolean Get hasRecords = CBool((CBool(BOF = True) And CBool(EOF = True)) = False)
[code]....
If RecordCount is defined as a fixed value in as a recordset property I would think the count would be faster as a single eval vs the multipart conversion/eval BOF/EOF method it is using.
how to clean up the code, perhaps some recommendations on how to have it working optimally. Maybe even some links for areas in particular that I should be more aware of. What functionality have I not employed here that I should have?
Option Strict On Imports System.Data.SqlClient Public Class Expenses Private MotorItems As New List(Of String)
Currently, one of our assignment for Physics are to create a program that can calculate series, parallel and combined circuit, with any number of capacitance. We are using Visual Basic.
1. How to make that when we click the 'Enter Capacitance', a pop up show and tell us to enter number of capacitance, or to enter value for a number of capacitance?
I'm passing a collection of links to a background worker. The first time I use it in my bgw, it works fine, the second time (after a thread sleep) it says property evaluation failed.
i want to build my own electronic circuit simulator which is use mathematical models to replicate the behavior of an actual electronic device or circuit. Simulating a circuits behavior before actually building it can i do that with vb.net is there any library that deal with simulation or something
My problem is I'm am trying to connect to a db2 table but no matter which connection type is use (adodb, oledb, db2) I keep getting the same error message when I get to this statement: objConn = New (adodb, oledb, db2).connection. "Property evaluation Failed".
I have a system created last year called the "Faculty Performance Evaluation System" in which the students will evaluate their instructors according to their performance. Now I'm trying to change that and the questions are to be loaded from the database. Here are my options for displaying the questions and the rating stars:
1. Using lots of labels placed in the form as well as images(stars)But this will consume lots and lots of codes and the number of questions is limited. Also, I can't do a control array in vb.net unlike in vb6 so it will be very long... 2. Using listview/datagrid?- is it possible to create this project with a listview containing the stars in the 2nd-6th column?, If so, how?
(It's ok to lose my background but the stars can't. Since using this kind of control will make my number of questions unlimited)- then, if I'm to choose this option, how would I save the results into my database? (fields: studnum, category, quesnum, rating)
I implemented a serial communication between a PC and a circuit based on ATMEL mP, managing the submission of correct / incorrect reception of commands ... The following code works, I wanted a block on the performance and reliability as it is for me very important part of this project that I'm doing.
Public Class frmTrattamento Dim IsStart As Boolean = False Dim inputData As String = "" Dim Stmp As String = "" Public Event DataReceived As IO.Ports.SerialDataReceivedEventHandler [Code] .....
I'm trying to develop a module that calculates voltages in a circuit based on setting for certain components. Is a module available to handle circuit calculations including parallel paths.
It titled E-Speech Door Access System. It security based system which user need register before use it. Now im using Visual Basic 2008 Express. I have use VB6 code it show error. Now i need the coding which when password spoken then signal need travel trough my laptop port. My laptop oni hv VGA port. So I plan 2 by USB parallel port.[code]...
I have written a programm with visual basic 2008 express edition and I'd like to use the parallel port to communicate with my self-made circuit. I want to controll 120 LEDs with the parallel port but I don't get it how. I know how to activate the databus but not how to activate the controle lines of the parallel port.
I am using the code below to export records in a datatable to an excel file using EPPlus.
Dim excelPackage = New ExcelPackage Dim excelWorksheet = excelPackage.Workbook.Worksheets.Add("DemoPage") excelWorksheet.Cells("A1").LoadFromDataTable(dt, True)[code]....
However, after walking through the code block, at Response.End(), I get an exception {Property evaluation failed.}
Update:
The error log is:
ERROR: System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at Reporting.Page_Load(Object sender, EventArgs e) in C:Reporting.aspx.vb:line 38
In VB.NET: If varShort is a Short and varBit is a value from 0 to 15, how can I set the bit in varShort identified by varBit without disturbing any of the other bits in varShort? My problem, of course, is with the most significant bit, bit 15. Since varBit is determined at runtime
[code]'when i enter 'Q' key output(textbox1.text) = 'qQ' how Show Q only''' 'and how i can set multi shortkey output = CTRL+TAB+CAPS LOCK,and bla bla , and send to Timer1' End Sub.[code]
1. i need to find the place / city / location from IP address. does anyone know about this?
2. I want to know if there is any way to get a short URL for the db entities(i.e; if i press my website and type a db content it should go to a new page)for ex i have a site called [URL] here in actual code if i press [URL], it redirect to new page to display the content of abc.Now, what i want is i need to type [URL] and it should redirect to new page with info abc.
I have created one silverlight application.In the application i have included two buttons named as SAVE and CANCEL. I want to give short cut keys for those two controls.For Example if user click CTRL+S it should save the data and CTRL+C it should cancel.
Private Sub myGrid_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles myGrid.KeyDown If e.KeyCode = Keys.Divide AndAlso e.Control Then
[Code].....
This works (For "Ctrl"+"/"), but the problem is that this works for any key different than "-". If I specify that the Keycode is Keys.Subtract (To use "Ctrl"+"-") it is never caught!
Private Sub myGrid_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles myGrid.KeyDown If e.KeyCode = Keys.Divide AndAlso e.Control Then Dim response = MsgBox("are you sure to delete a record?", vbYesNo) If response = vbYes Then
[code]....
This works (For "Ctrl"+"/"), but the problem is that this works for any key different than "-". If I specify that the Keycode is Keys.Subtract (To use "Ctrl"+"-") it is never caught!