CreateForm Method  
 

Create a new form, replacing the current form.

Syntax

object.CreateForm( [Action], [Method], [FormType] )

Parameters

Action
A string which specifies the name of the resource that the form data will be submitted to. Typically this is the name of a script that is executed on the server. If this argument is omitted, the value of the FormAction property is used as the default value. If the FormAction property is undefined, the value of the Resource property will be used as the default value.
Method
An integer value which specifies how the form data will be submitted to the server. This argument may be one of the following values:
Value Constant Description
0 httpMethodDefault The form data should be submitted using the default method, using the GET command.
1 httpMethodGet The form data should be submitted using the GET command. This method should be used when the amount of form data is relatively small. If the total amount of form data exceeds 2048 bytes, it is recommended that the POST method be used instead.
2 httpMethodPost The form data should be submitted using the POST command. This is the preferred method of submitting larger amounts of form data. If the total amount of form data exceeds 2048 bytes, it is recommended that the POST method be used.
FormType
An integer value which specifies the type of form and how the data will be encoded when it is submitted to the server. This argument may be one of the following values:
Value Constant Description
0 httpFormDefault The form data should be submitted using the default encoding method.
1 httpFormEncoded The form data should be submitted as URL encoded values. This is typically used when the GET method is used to submit the data to the server.
2 httpFormMultipart The form data should be submitted as multipart form data. This is typically used when the POST method is used to submit a file to the server. Note that the script must understand how to process multipart form data if this form type is specified.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Remarks

The CreateForm method is used to create a new form that will be populated with values and then submitted to the server for processing.

Example

HttpClient1.CreateForm "/login/php", httpMethodPost, httpFormEncoded
HttpClient1.AddField "UserName", strUserName
HttpClient1.AddField "Password", strPassword

nError = HttpClient1.SubmitForm(strResult)
If nError > 0 Then
    MsgBox HttpClient1.LastErrorString, vbExclamation
    Exit Sub
End If

See Also

AddField Method, AddFile Method, CreateForm Method, DeleteField Method, SubmitForm Method