SendPrivateMessage MethodSendPrivateMessage Method*
*



Contents  *



Index  *Topic Contents
*Previous Topic: SendInvitation Method
*Next Topic: SendProtocolMessage Method

SendPrivateMessage Method

Sends a private text or data message to one or several users.

Syntax

object.SendPrivateMessage PrivateMessageType, Message, RecipientNicknames[, DataMessageTag] 

Parameters

objectRequired. An object expression that evaluates to an MsChatPr control.
PrivateMessageTypeRequired. A long value that is a combination of some of the enumPrivateMessageType enumeration values. The values that can be used are:
pmtNormal&H0.
pmtNotice&H1.
pmtData&H2.
pmtDataRequest   &H4.
pmtDataReply&H8.
pmtDataRaw&H10.
pmtVersion&H40.
pmtLagTime&H80.
pmtLocalTime&H100.
pmtAction&H200.
pmtSound&H400.
pmtCTCP&H800.

Except for pmtNormal, all the above values are mutually exclusive.

The valid PrivateMessageType values are:
pmtNormal
pmtNotice
pmtData
pmtDataRequest
pmtDataReply
pmtData + pmtDataRaw
pmtDataRequest + pmtDataRaw
pmtDataReply + pmtDataRaw
pmtVersion + pmtNormal
pmtLagTime + pmtNormal
pmtLocalTime + pmtNormal
pmtAction + pmtNormal
pmtSound + pmtNormal
pmtCTCP + pmtNormal
pmtVersion + pmtNotice
pmtLagTime + pmtNotice
pmtLocalTime + pmtNotice
pmtAction + pmtNotice
pmtSound + pmtNotice
pmtCTCP + pmtNotice

MessageRequired. A variant that can be a string, a number, an array of strings, an array of numbers, or an array of variants that can be strings and numbers. The variant types allowed for these numbers are:
VT_UI1
VT_I2
VT_I4
VT_R4
VT_R8
VT_BOOL
VT_ERROR
VT_CY
VT_DATE

Message is the actual message to send.

RecipientNicknamesRequired. A variant that can be a string, an array of strings, or an array of variants that are strings that represent the recipients' nicknames.
DataMessageTagOptional. This variant will be a non-empty string when sending data (that is, the pmtData, pmtDataRequest, or pmtDataReply flag is set). This parameter must be empty or missing in all other cases.

Remarks

When sending data and the pmtDataRaw flag is not set, the control packages the Message parameter into an array of bytes and uses an internal header to tell the recipients that the message comes from an MsChatPr control. However, when the pmtDataRaw flag is also set, the Message parameter can only be a postprocessed string, a byte, an array of bytes, or an array of variants that are bytes. A postprocessed string is a string that was modified using the regular conversion scheme.
Character    Becomes string
'\0' "\0"
'\' "\\"
'\n' "\n"
'\r' "\r"
'\t' "\t"
' ' "\b"
',' "\c"

When sending raw data, the control simply converts the Message parameter into a postprocessed string without using an internal header. This way all clients can handle the data message.

Examples

1. Send a regular string to a user:

MsChatPr1.SendPrivateMessage pmtNormal, "Hi there!", "Mila"

2. Send a notice to a user:

MsChatPr1.SendPrivateMessage pmtNotice, "Bye now!", "Zorg"

3. Request version information:

MsChatPr1.SendPrivateMessage pmtVersion, " ", "Mila"

4. Send version information:

MsChatPr1.SendPrivateMessage pmtVersion,"MsChatPr ActiveX Control V2.0 
    used in VB 5.0 Application Chat-oh", "Mila"

5. Request lag time:

MsChatPr1.SendPrivateMessage pmtLagTime, CStr(Timer), "Mila"

6. Request local time:

MsChatPr1.SendPrivateMessage pmtLocalTime, " ", "Mila"

7. Send an action to a user (CTCP action):

MsChatPr1.SendPrivateMessage pmtAction, "is eating couscous....", "Kimmy"

8. Send a sound to a user (CTCP sound):

MsChatPr1.SendPrivateMessage pmtSound, "couscous.wav Isn't that cool?", "Kimmy"

9. Send a CTCP message to a user:

MsChatPr1.SendPrivateMessage pmtCTCP, "FINGER", "Mila"

10. Send text to several users:

Dim strRecipients(1 To 3) As String
strRecipients(1) = "Charlotte"
strRecipients(2) = "Zorg"
strRecipients(3) = "Arthur"
MsChatPr1.SendPrivateMessage pmtNormal, "I'm a cook too...", strRecipients	
'or
Dim vRecipients(1 To 3) As Variant
vRecipients(1) = "Charlotte"
vRecipients(2) = "Zorg"
vRecipients(3) = "Arthur"
MsChatPr1.SendPrivateMessage pmtNormal, "I'm a cook too...", vRecipients

11. Send a string as data to a user:

MsChatPr1.SendPrivateMessage pmtData, "And a painter as well.", "Mila", "_FOO_"

12. Send a number to a user:

MsChatPr1.SendPrivateMessage pmtData, 1156, "Charlotte", "X"

13. Send an array of numbers to users:

Dim iValues(1 To 4) As Integer
iValues(1) = 10
iValues(2) = -22
iValues(3) = 123
iValues(4) = 0
Dim strRecipients(1 To 3) As String
strRecipients(1) = "Charlotte"
strRecipients(2) = "Zorg"
strRecipients(3) = "Arthur"
MsChatPr1.SendPrivateMessage pmtData, iValues, strRecipients, "COORD"
'or 
Dim vValues(1 To 4) As Variant
vValues(1) = 10
vValues(2) = -22
vValues(3) = 123
vValues(4) = 0
Dim vRecipients(1 To 3) As Variant
vRecipients(1) = "Charlotte"
vRecipients(2) = "Zorg"
vRecipients(3) = "Arthur"
MsChatPr1.SendPrivateMessage pmtData, vValues, vRecipients, "COORD"

14. Send an array of strings to a user:

Dim strValues(1 To 4) As String
strValues(1) = "Blue"
strValues(2) = "Green"
strValues(3) = "Red"
strValues(4) = "White"
MsChatPr1.SendPrivateMessage pmtData, strValues, "Prout", "COLORS"
'or 
Dim vValues(1 To 4) As Variant
vValues(1) = "Blue"
vValues(2) = "Green"
vValues(3) = "Red"
vValues(4) = "White"
MsChatPr1.SendPrivateMessage pmtData, vValues, "Prout", "COLORS"

15. Send an array of variants to a user:

Dim vValues(5 To 10) As Variant
vVariant(5) = Now
vVariant(6) = "Your turn to play...."
vVariant(7) = -10
vVariant(8) = 5
vVariant(9) = -12.689
vVariant(10) = 9876582146
MsChatPr1.SendPrivateMessage pmtData, vValues, "Zoulou", "TheHugeOne"

16. Send raw data to a user:

'A postprocessed string
MsChatPr1.SendPrivateMessage pmtData + pmtDataRaw, "dhe\rotk\\nsk\0k45v\0zxa\\v", 
    "Arthur", "ProcessedString"
'One byte
Dim byt As Byte
byt = 56
MsChatPr1.SendPrivateMessage pmtData + pmtDataRaw,byt, "Arthur", "OneByte"
'An array of bytes
Dim rgBytes(1 To 3) As Byte
rgBytes(1) = 15
rgBytes(2) = 98
rgBytes(3) = 2
MsChatPr1.SendPrivateMessage pmtData + pmtDataRaw,
    rgBytes, "Arthur", "ArrayOfBytes"
'An array of Variants that are bytes
Dim vByt(1 To 3) As Variant
vByt(1) = CByte(15)
vByt(2) = CByte(98)
vByt(3) = CByte(2)
MsChatPr1.SendPrivateMessage pmtData + pmtDataRaw, vByt, "Arthur", 
    "ArrayOfVariants"

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.