Microsoft KB Archive/159426

= XCLN: How to Write Listbox Items to an E-form Package =

Article ID: 159426

Article Last Modified on 10/28/2006

-

APPLIES TO


 * Microsoft Exchange Client 5.5
 * Microsoft Exchange Client 5.0
 * Microsoft Exchange Client 4.0
 * Microsoft Exchange Client 5.0

-



This article was previously published under Q159426



SUMMARY
When you use the Microsoft Exchange 4.0 Electronic Forms Designer to create a custom E-form that has a listbox, you can set the initial content of the listbox by double-clicking the listbox to open up a Field Properties dialog box, choosing the Initial Value tab, and setting the list items for the listbox.

But sometimes you may want to have an initially blank listbox and have the E-form sender dynamically add or remove the list items. In this case, you have to modify the Visual Basic code generated by the E-form Designer to write the content of the listbox to the E-form package. Otherwise, the receiver of the E-form will receive a blank listbox. This article illustrates the techniques of writing the listbox items to an E-form package.



MORE INFORMATION
 Use the Microsoft Exchange E-form Designer Wizard to generate an one- window electronic form called List.efp. Add a listbox to the E-form. Compile and install the form. This will generate a 16-bit Visual Basic project called List.vbp. Load List.vbp into a 16-bit version of Visual Basic.  Add a Command button, Command1, to Window1.Frm. In the click event, populate the list box:

Private Sub Command1_Click Dim i As Integer For i = 0 To 10 ListBox1_Ctrl.AddItem "Item " & i         Next i      End Sub   Add a public function to Window1.Frm to write the list items of ListBox1_Ctrl into a single Visual Basic Variant type variable:

Public Function CreateVariant As Variant Dim varRet As Variant Dim strTemp As String ReDim strTemp(ListBox1_Ctrl.ListCount) As String Dim i As Integer For i = 0 To ListBox1_Ctrl.ListCount - 1 strTemp(i) = ListBox1_Ctrl.List(i) Next i         CreateVariant = strTemp 'store an array into a variant End Function  Remove the ListBox1_Ctrl_Click procedure from the Window1.Frm.  In the Window_Store procedure of the Window1.Frm, add the following statement

ListBox1_Ctrl_Val = CreateVariant

before the following statement

Call SetMapiProp(ctlSubject.Text, "MAPI_Subject_Custom",vbString, Msg)   In the Window_Load procedure, comment out the following statement:

If (VarType(varTemp) And vbArray) = vbArray Then varTemp = varTemp(0) </li>  Change the SetListBoxValue subroutine in the Global.bas to the following:

Public Sub SetListBoxValue(ByVal var As Variant, ctl As Control, _        inType As Integer) Dim Index As Integer Dim lstMost As Integer

If IsNull(var) Then Exit Sub If VarType(var) < vbArray Then Exit Sub ctl.Clear lstMost = UBound(var) For Index = 0 To lstMost - 1 ctl.AddItem var(Index) Next Index

End Sub </li> Rebuild the executable file and install it.</li></ol>

To test the newly installed E-form, the sender loads the form using the Microsoft Exchange client. The sender first clicks the Command1 button to populate the listbox and then click the Send button. When the receiver opens up the received form, the list items of the listbox are received.

Additional query words: Eforms VB Eform

Keywords: kbhowto kbusage KB159426

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.