View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Daniel[_8_] Daniel[_8_] is offline
external usenet poster
 
Posts: 2
Default communication

This site does not provide me enough info as a beginner in the VB world... Can you help me integrate it into a source code somehow

this is my routine for connecting and retrieving data as of now

Public Function Connect(requestCommand As String) As Strin
Const INTERNET_OPEN_TYPE_PRECONFIG =
Const INTERNET_SERVICE_HTTP =

Dim returnString As Strin
Dim sBuffer As String * 204
Dim Result As Strin
Dim lBufferLength As Lon
Dim msg As Strin

Dim INTERNET_DEFAULT_HTTP_POR
Dim HTTP_QUERY_CONTENT_LENGT
Const INTERNET_FLAG_RELOAD = &H8000000
Dim errorMsg As Strin
Dim fullCommand As Strin
Dim hSessio

lBufferLength = Len(sBuffer

hInternetOpen =
hInternetConnect =
hHttpOpenRequest =
errorMsg = "
fullCommand = ThisWorkbook.ServletName + requestComman
INTERNET_DEFAULT_HTTP_PORT = ThisWorkbook.ServletPor


hInternetOpen = InternetOpen("CD",
INTERNET_OPEN_TYPE_PRECONFIG,
vbNullString,
vbNullString,
0

If (hInternetOpen = 0) The
returnString = "Error
errorMsg = "Cannot initialize the internetconnection!
GoTo endFunctio
End I

hInternetConnect = InternetConnect(hInternetOpen,
ThisWorkbook.ServletUrl,
INTERNET_DEFAULT_HTTP_PORT,
vbNullString,
vbNullString,
INTERNET_SERVICE_HTTP,
0,
0

If (hInternetConnect = 0) The
returnString = "Error
errorMsg = "Cannot access the servlet
GoTo endFunctio
End I

hHttpOpenRequest = HttpOpenRequest(hInternetConnect,
"POST",
fullCommand,
vbNullString,
vbNullString,
0,
INTERNET_FLAG_RELOAD,
0

If (hHttpOpenRequest = 0) The
returnString = "Error
errorMsg = "Error in opening the requestchannel
GoTo endFunctio
End I

bRet = HttpSendRequest(hHttpOpenRequest,
vbNullString, 0, 0, 0

If (bRet = 0) The
returnString = "Error
errorMsg = "Error in sending request
GoTo endFunctio
End I

HttpQueryInfo hHttpOpenRequest, HTTP_QUERY_CONTENT_LENGTH, ByVal sBuffer, lBufferLength,
InternetReadFile hHttpOpenRequest, sBuffer, ByVal lBufferLength, lBufferLengt
Result = "
Result = Result + Left$(sBuffer, lBufferLength
While lBufferLength <
InternetReadFile hHttpOpenRequest, sBuffer, ByVal lBufferLength, lBufferLengt
Result = Result + Left$(sBuffer, lBufferLength
Wen

bRet = InternetCloseHandle(hHttpOpenRequest
bRet = InternetCloseHandle(hInternetConnect
bRet = InternetCloseHandle(hInternetOpen

returnString = Resul
Connect = returnStrin
Exit Functio
endFunction
msg = MsgBox(errorMsg, vbCritical, "Error"
Connect = returnStrin
End Functio