Retrieving non-string values
Charles Yeomans
yeomans at desuetude.com
Wed Jan 14 15:38:15 CST 2004
On Jan 14, 2004, at 2:35 PM, chuck hinkle wrote:
>
>>
>> On Jan 14, 2004, at 1:38 PM, chuck hinkle wrote:
>>
>>>
>>>
>>> I don't know why I continue to be confused by this topic; it doesn't
>>> seem
>>> like it should be difficult.
>>>
>>>
>>> I have a table with a variable in it named Vsize, and it's defined
>>> as a
>>> vuShort. In my RB program, I'm having trouble moving it to a variable
>>> dimensioned as an integer.
>>>
>>> I know that if my variable were a string, I could use
>>> VSize = my_cursor.field("VSize").getstring
>>>> From what I read, it seems like I need to do
>>> VSize = vushort(my_cursor.field("VSize")) but that gives me a
>>> Type
>>> Mismatch error (perhaps because I'm trying to move a vushort to an
>>> integer?).
>>>
>>> Any advice on this one?
>>> chuck
>>>
>>
>> You should use my_cursor.UShortField("VSize").value, which returns an
>> integer. Beware that calling one of these functions (like
>> UShortField)
>> on a field of the wrong type usually results in a crash, so you might
>> consider adding an assertion before it that checks the type of
>> my_cursor.Field("VSize"), at least for debug builds.
>>
>> Charles Yeomans
>>
>
>
> I still get the Type Mismatch error when I try to compile it.
> I'm guessing that it's because I can't set an Integer variable equal to
> the result of the UShortfield command; integers are 4 bytes and vushort
> fields are 2 bytes. But what RB field type would be appropriate to
> use? Do
> I need to move it into a Variant?
>
Bad guess. You're confusing the structure of a UShort field with the
declared type of the property UShort.Value, which is Integer. in your
code above, it appears that you're declaring the type of VSize to be
UShort. If so, then the following code makes no sense.
VSize = my_cursor.field("VSize").getstring
Here, VSize is a UShort, while GetString returns a String.
Perhaps you could just post your code.
Charles Yeomans
More information about the Valentina
mailing list