Re: shorts and longs



thanks for the explanation, bob. i think in my case i can accept the value as a long
instead of an integer.


"Bob Butler" <tiredofit@xxxxxxxxxx> wrote in message
news:eYQKjCgkFHA.3968@xxxxxxxxxxxxxxxxxxxxxxx
> "Lance" <nunya@xxxxxxxxxxxx> wrote in message
> news:ejvfy8fkFHA.2916@xxxxxxxxxxxxxxxxxxxx
>> it was my understanding that a c type short was equal to a vb type
>> integer, and a c type long was equal to a vb type long.
>
> ...c type "int" is the same as a VB type long
>
>> according to the tif file specs, the compression tag (259) stores
>> it's value (either 1, 2, 3, 4, 5, 6, or 32773) as a short type (a vb
>> integer) but as you can see, one of the valid values of the
>> compression type is 32773, which is out of the range of a vb integer.
>> so, when i Dim m_Compression as Integer and the return value is
>> 32773, i get an overflow obviously. i can change it to Dim
>> m_Compression as Long, but will that cause any trouble i'm not aware
>> of?
>
> 32773 is valid for an unsigned 16-bit value; it is not valid for a signed
> 16-bit value and unfortunately VB only supports signed values. If you read
> the 16-bit value from a file into an Integer variable you will get a
> negative number (-32763) which is fine since it will have the same bit
> pattern as +32773 so it is essentially equivalent. If you are calling a
> function that returns a 16-bit value then it should also work but if you
> call a function that returns a 32-bit value then VB will complain about not
> being able to convert to Integer because it will be outside the range. You
> can accept that value into a VB Long to avoid the error and then mask off
> the lower 16 bits but how you handle it will depend on what the exact
> situation is. What are you calling that is giving you the return value and
> how is that function defined?
>
> --
> Reply to the group so all can participate
> VB.Net: "Fool me once..."
>


.



Relevant Pages

  • Re: shorts and longs
    ... > according to the tif file specs, the compression tag stores ... when i Dim m_Compression as Integer and the return value is ... What are you calling that is giving you the return value and ...
    (microsoft.public.vb.general.discussion)
  • Re: Can I Make This Computation Shorter?
    ... It works for me in XL97 without a range, calling it as =SquareIt, ... Dim x As Long ... Price = stock price ... can I go one step further and directly calculate sum ...
    (microsoft.public.excel.misc)
  • Re: Why db.OpenRecordset("SQL STRING HERE", dbOpenDynaset) is not working ?
    ... Dim r As Recordset ... I generally pass calling ... Function AllCarsNbatchReady4906(CallingProcedure As String) As Boolean ... name in the error message box if the procedure err's at runtime. ...
    (comp.databases.ms-access)
  • Export to Excel Code - Please Review
    ... I am calling the code as follows where the file name is ... Dim FileName As String, MyRecs As DAO.Recordset, TestIt As Boolean ... Dim RSRange As Excel.Range ... vbOKOnly, "Function SaveRecordsetToExcel()" ...
    (microsoft.public.access.modulesdaovba)
  • Re: shorts and longs
    ... > it was my understanding that a c type short was equal to a vb type ... > according to the tif file specs, the compression tag stores it's ... so, when i Dim ... that "compression tag" you're speaking of is an ...
    (microsoft.public.vb.general.discussion)