Quantcast
Viewing all articles
Browse latest Browse all 15758

User Control byte array problem

I am in the process of converting SimpleSock into a User Control, and I have run into a problem transferring a byte array.

The User Control contains SimpleSock.cls and modSocket.bas, but we cannot communicate directly with either of these. We must communicate with the User Control. So the User Control instantiates a dummy class which simply forwards the information to these 2 modules and visa versa.
Code:

    'create an instance of SimpleSock
    Set cmSocket = New SimpleSock

We declare all the "bridge" functions and properties in the control. The idea being that when the user calls a function in the control, we call the cmSocket function. When cmSocket raises an event we raise an event. When the user sets a property we set the cmSocket property. When the user retrieves a property we retrieve the cmSocket property and pass the result to the user.

Everything in SimpleSock uses byte arrays, but contains routines to convert ANSI strings and Unicode strings to byte arrays. If I pass the message to the User Control as a string, it works fine.
Code:

(user)
    mClient.sOutBuffer = GetRequest

(Control)
Public Property Let sOutBuffer(sNewValue As String)
    cmSocket.sOutBuffer = sNewValue
End Property

(Class)
Public Property Let sOutBuffer(sNewValue As String)
    Dim bTmp() As Byte
    bTmp = StrToByte(sNewValue)
    Call AddByte(m_bSendBuffer, bTmp)
End Property

But if I pass the message as a byte array, it fails with no error.
Code:

(user)
    mClient.bOutBuffer = StrToByte(GetRequest)

(Control)
Public Property Let bOutBuffer(bNewValue() As Byte)
    cmSocket.bOutBuffer = bNewValue
End Property

(Class)
Public Property Let bOutBuffer(bNewValue() As Byte)
    Call AddByte(m_bSendBuffer, bNewValue)
End Property

Any ideas?

J.A. Coutts

Viewing all articles
Browse latest Browse all 15758

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>