[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Null value into an integer variable



On 19/4/24 6:52 pm, BB wrote:

On 19/4/24 6:50 pm, BB wrote:
On 19/4/24 6:25 pm, Mayost Sharon wrote:

Hello


Public Sub Main()
      Dim sVar As String
   Dim iVar As Integer

   sVar = "gb"
   iVar = 3
      sVar = Null
   iVar = Null
   End


When 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 error

Is this normal?

Thank you


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.

This 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


By the way, you are hereby charged with thread stealing and will be tried and summarily executed!
😁


Follow-Ups:
Re: Null value into an integer variableChristof Thalhofer <chrisml@xxxxxxxxxxx>
References:
GRIDVIEW color and size"Mayost Sharon" <sharon@xxxxxxxxx>
Re: GRIDVIEW color and sizeT Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: GRIDVIEW color and sizeT Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: GRIDVIEW color and size"Mayost Sharon" <sharon@xxxxxxxxx>
Re: GRIDVIEW color and sizeT Lee Davidson <t.lee.davidson@xxxxxxxxx>
Null value into an integer variable"Mayost Sharon" <sharon@xxxxxxxxx>
Re: Null value into an integer variableBB <adamnt42@xxxxxxxxx>
Re: Null value into an integer variableBB <adamnt42@xxxxxxxxx>