troubleshooting Question

How to a public function from an onclick sub in Ms Access

Avatar of Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.ScFlag for Zambia asked on
Microsoft AccessVBA
8 Comments1 Solution30 ViewsLast Modified:
Dear All;

I'm struggling to a call this function below to be used in an on click event in Ms Access, any idea here?

Public Function RecvAscii(dataBuf As String, ByVal maxLength As Integer) As Integer
    Dim count As Long
    Dim c As String * 12288
    Dim length As Integer
   
    dataBuf = ""
    While length < maxLength
        DoEvents
        count = recv(socketId, c, 12288, 0)
        If count < 1 Then
            RecvAscii = RECV_ERROR
            dataBuf = Chr$(0)
            Exit Function
        End If
       
        If c = Chr$(10) Then
           dataBuf = dataBuf + Chr$(0)
           RecvAscii = NO_ERROR
           Exit Function
        End If
       
        length = length + count
        dataBuf = dataBuf + c
    Wend
   
    RecvAscii = RECV_ERROR
   
End Function

Open in new window

I want to get the data from using above function so that once I get it then I have an opportunity to trim it to get only what I need because not all the data is required here:

The VBA below need to use the above function to polish up the needed data and that is where the problem is how to call that function and use its data into the cutting area

Private Sub CmdCread_Click()
Dim lngstatus As Long
Dim strData As String
Dim strFindata As String
Dim strDataAudit As String
' Read maximum bytes from TCP/IP Port.
lngstatus = RecvAscii(strData, 40000)
'After receiving all the data I want to trim so that I remain with the required data
strFindata = Mid(strData, 8)
strDataAudit = Chr(91) & (Left(strFindata, Len(strFindata) - 6278)) & Chr(34) & "}" & Chr(93)

Open in new window

ASKER CERTIFIED SOLUTION
Hankwembo Christopher,FCCA,FZICA,CIA,MAAT,B.A.Sc
Managing Partner

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 8 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 8 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004