[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Null value into an integer variable
[Thread Prev] | [Thread Next]
- Subject: Re: Null value into an integer variable
- From: Rolf-Werner Eilert <rwe-sse@xxxxxxxxxx>
- Date: Fri, 19 Apr 2024 12:53:31 +0200
- To: user@xxxxxxxxxxxxxxxxxxxxxx
Am 19.04.24 um 11:20 schrieb BB:
On 19/4/24 6:25 pm, Mayost Sharon wrote:Very much so! A string of zero length is considered a null or vice versa a null is considered a string of zero length. But consider the internal (memory) representation of an integer. There is no way to represent a null value.Hello Public Sub Main() Dim sVar As String Dim iVar As Integer sVar = "gb" iVar = 3 sVar = Null iVar = Null EndWhen I put an Null value into a variable of type string I don't get an error and the variable gets a value of ""But when I put an Null value into a variable of integer type it gives an errorIs this normal? Thank youThis is of course a big PIA when dealing with databases where integer columns can contain nulls and that has a very specific meaning i.e. "no value has been set". I have to date, after some time considering this, have not arrived at a viable solution.Why do you want to set an integer variable to Null? b
Usually I try to catch this case by checking for "" and IsNull(Val(...)) like
If sMyString = "" Then iMyInteger = 0 Else If IsNull(Val(sOriginal)) Then iMyInteger = 0 Else iMyInteger = Val(sOriginal) End If End If to be completely sure. Regards Rolf
Re: Null value into an integer variable | BB <adamnt42@xxxxxxxxx> |
GRIDVIEW color and size | "Mayost Sharon" <sharon@xxxxxxxxx> |
Re: GRIDVIEW color and size | T Lee Davidson <t.lee.davidson@xxxxxxxxx> |
Re: GRIDVIEW color and size | T Lee Davidson <t.lee.davidson@xxxxxxxxx> |
Re: GRIDVIEW color and size | "Mayost Sharon" <sharon@xxxxxxxxx> |
Re: GRIDVIEW color and size | T Lee Davidson <t.lee.davidson@xxxxxxxxx> |
Null value into an integer variable | "Mayost Sharon" <sharon@xxxxxxxxx> |
Re: Null value into an integer variable | BB <adamnt42@xxxxxxxxx> |