Share via


IAppFrameWork::Option Method [C++]

Use this method to generate an OPTION item in an HTML form selection list with the value and selection state that you specify.

Definition

[C++]

HRESULT IAppFrameWork::Option(VARIANTvtVal1,
  VARIANTvtVal2,
  BSTR*pbstrRet);

[Visual Basic]

Function Option(vtVal1 As Variant,
  vtVal2 As Variant) As String

Parameters

  • vtVal1[C++]
    [in] A VARIANT that contains the value of the option in the selection list.
  • vtVal1[Visual Basic]
    A Variant that contains the value of the option in the selection list.
  • vtVal2[C++]
    [in] A VARIANT that contains a value that indicates whether the list option is the selected option. If the vtVal2 parameter is equal to the vtVal1 parameter, then the HTML keyword SELECTED is inserted in the definition of the option list.
  • vtVal2[Visual Basic]
    A Variant that contains a value that indicates whether the list option is the selected option. If the vtVal2 parameter is equal to the vtVal1 parameter, then the HTML keyword SELECTED is inserted in the definition of the option list.
  • pbstrRet[C++]
    [out, retval] A pointer to a BSTR used to return the OPTION item.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully. See the Error Values section for more details.

[Visual Basic] If this method completes successfully, it returns a String that contains the OPTION item.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and standard COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to standard COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors. Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

[C++] The pbstrRet parameter points to valid data only if the method completed successfully.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

Example

[Visual Basic]

' oAppFrameWork is a Commerce.AppFrameWork object.
' The following example generates a selection field in an
' HTML form to enable the customer to select the expiration
' year of their credit card. The Option method generates
' <OPTION VALUE="> tags and marks the current year 
' as selected: 
<% iyear = Year(date) %>

<SELECT NAME="_cc_expyear">
    <% = oAppFrameWork.Option(2000, iyear) %> 2000
    <% = oAppFrameWork.Option(2001, iyear) %> 2001
    <% = oAppFrameWork.Option(2002, iyear) %> 2002
    <% = oAppFrameWork.Option(2003, iyear) %> 2003
</SELECT> 
' Following is the HTML output that is produced,
' assuming that the current year is 2001:
<SELECT NAME="_cc_expyear">
    <OPTION VALUE="2000"> 2000
    <OPTION VALUE="2001" SELECTED> 2001
    <OPTION VALUE="2002"> 2002
    <OPTION VALUE="2003"> 2003
</SELECT>

See Also

[C++]AppFrameWork Object

[Visual Basic]AppFrameWork Object

Copyright © 2005 Microsoft Corporation.
All rights reserved.