Connecting Directly with the Logon Control 
This example shows the direct use of the Logon control in an application serving as an OLE Automation Client:
Dim oLogonCtrl as Object
Dim oConnection as Object
Rem ***Create the Logon Control
Set oLogonCtrl = CreateObject (
" SAP.Logoncontrol.1 " )Rem ***Get a connection object
Set oConnection = oLogonCtrl.NewConnection
Rem ***Try to connect to the R/3 System
if oConnection.Logon (Form.hWnd, FALSE) = FALSE then
MsgBox "R/3 connection failed"
end if
Rem ***Now the connection is established: you can call your functions
You can also place connection code in an event subroutine:
Dim oConnection as Object
Private Sub SAPLogonControl1_Click()
Set oConnection = SAPLogonControl.NewConnection
Rem ***Try to connect to the R/3 System
if oConnection.Logon (Form.hWnd, FALSE) = FALSE then
MsgBox "R/3 connection failed"
exit subif
end sub
Rem ***Now the connection is established: you can call your functions