sx_PutVariant

<< Click to Display Table of Contents >>

Navigation:  Apollo API Listing >

sx_PutVariant

VB Declaration

Declare Sub sx_PutVariant Lib "Apollo9.dll"

(ByVal cpFieldName As String,

pVariant As Variant)

C Declaration

Description

Replace the contents of a field with a variant value.

This function frees the Visual Basic programmer from defining the data type of the field replacement as long as the variable containing the replacement value has been explicitly defined as a variant.

The passed value is automatically converted to the correct data type before replacing the contents of the field.

If the replacement data has not been explicitly dimensioned as a variant, use the Visual Basic CVar function to convert it to a variant.

Parameters

cpFieldName: The name of the field optionally qualified with an alias.

pVariant: A variant containing the replacement data. Logical field values should be passed as either zero (FALSE) or -1 (TRUE). Date strings must be formatted according to the setting of sx_SetDateFormat and sx_SetCentury.

Type Conflicts

The following is illegal:

sx_PutVariant "master->name", sx_GetVariant("batch->name")

sx_GetVariant returns a string and not a variant. If its return value is equated to an explicitly dimensioned variant, that return value becomes a variant. In the code fragment above, we are attempting to replace a variant with a string, and this is illegal. The code may easily be repaired with

sx_PutVariant "master->name", CVar(sx_GetVariant("batch->name"))

VB Example

Dim gTotal As Variant

 

' calculate total balance

gTotal = 0.0

sx_GoTop

Do While Not sx_Eof()

gTotal = gTotal + CVar(sx_GetVariant("balance"))

sx_Skip 1

Loop

 

' update total in last record

sx_GoBottom

sx_PutVariant "totbal", gTotal

gTotalBox.Text = gTotal

C Example

See Also

sx_GetVariant