VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsNetworkMessage"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private m_sMsgType As String
Private m_nSenderNumber As Long
Private m_saParamaters() As String
Private m_nNumParamaters As Long
Private m_nMaxNumParamaters As Long

Public Property Get SenderNumber() As Long
    SenderNumber = m_nSenderNumber
End Property
Public Property Let SenderNumber(nNewVal As Long)
    m_nSenderNumber = nNewVal
End Property

Public Property Get MsgType() As String
    MsgType = m_sMsgType
End Property
Public Property Let MsgType(sNewVal As String)
    m_sMsgType = sNewVal
End Property

Public Property Get Paramater(nIndex As Long) As String
    Paramater = m_saParamaters(nIndex - 1)
End Property

Public Property Get ParamaterCount() As Long
    ParamaterCount = m_nNumParamaters - 1
End Property
Public Function NumberOfParamaters() As Long
    NumberOfParamaters = m_nNumParamaters
End Function
Public Function AddParamater(sNewVal As String)

    If m_nNumParamaters > m_nMaxNumParamaters Then
        m_nMaxNumParamaters = m_nMaxNumParamaters * 2
        ReDim Preserve m_saParamaters(0 To m_nMaxNumParamaters) As String
    End If
    
    m_saParamaters(m_nNumParamaters) = sNewVal
    m_nNumParamaters = m_nNumParamaters + 1
    
End Function

Public Function FormatForSending() As String
    
    Dim i As Long
    
    For i = 1 To m_nNumParamaters
        If i > 1 Then FormatForSending = FormatForSending & g_cMsgDelim
        FormatForSending = FormatForSending & Paramater(i)
    Next i

End Function

Private Sub Class_Initialize()
    m_nNumParamaters = 0
    m_nMaxNumParamaters = 10
    ReDim m_saParamaters(0 To m_nMaxNumParamaters) As String
End Sub

Public Sub ParseMessage(sMsg As String)

    Dim sTemp As String
    
    sTemp = sMsg
    m_sMsgType = Left(sTemp, InStr(sTemp, g_cMsgDelim) - 1)
        sTemp = Right(sTemp, Len(sTemp) - InStr(sTemp, g_cMsgDelim) - Len(g_cMsgDelim) + 1)
    m_nSenderNumber = Left(sTemp, InStr(sTemp, g_cMsgDelim) - 1)
        sTemp = Right(sTemp, Len(sTemp) - InStr(sTemp, g_cMsgDelim) - Len(g_cMsgDelim) + 1)
    
    
    'Get all the paramaters
    While InStr(1, sTemp, g_cMsgDelim) > 0
        Call AddParamater(Left(sTemp, InStr(sTemp, g_cMsgDelim) - 1))
        sTemp = Mid(sTemp, InStr(sTemp, g_cMsgDelim) + Len(g_cMsgDelim))
    Wend

End Sub
