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

Re: Null value into an integer variable


Il 19/04/24 10:55, Mayost Sharon ha scritto:
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



Maybe something like this will be enough for you (*)? As long as this
isn't heresy...

Regards
Gianluigi

(*)
Public Sub Main()

  Dim vIntero As Variant

  vIntero = 450000
  Print IntValue(vIntero)
  vIntero = 2200000000
  Print IntValue(vIntero)
  vIntero = -2200000000
  Print IntValue(vIntero)
  vIntero = "PIPPO"
  Print IntValue(vIntero)

End

Private Sub IntValue(value As Variant) As Variant

  If value <= 2147483647 And If value >= -2147483648 Then Return value
  Return Null
Catch
  Return Null

End


Follow-Ups:
Re: Null value into an integer variableBB <adamnt42@xxxxxxxxx>
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>