Link to home
Start Free TrialLog in
Avatar of calahanpat
calahanpat

asked on

Net send syntax

I am making a simple netsend interface.
I have made a project with two text boxes and a command button. The command button will do the following

shell "netsend workstation message"

what I need to know is how to make the following happen

text1.text=workstation
text2.text=message

how would the statement then go??

I have tried the following to no end

text1.text=workstation
text2.text=message

shell "netsend " ' workstation '";" ' message '""

what is the right way to do it??
ASKER CERTIFIED SOLUTION
Avatar of DRRYAN3
DRRYAN3

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Try this and place them in a module. Pass in

Option Explicit

Public Declare Function NetMessageBufferSend Lib "NETAPI32.DLL" _
(yServer As Any, yToName As Byte, yFromName As Any, yMsg As Byte, _
ByVal lSize As Long) As Long
Public Const NERR_Success As Long = 0&
Public gstrMessage() As String
Public gstrTime()    As String
'Public AddressBk_Type As Integer  ' 1:Add to sender    2: Edit     3: Delete

Public Function BroadcastMessage(UserOrMachine As String, _
FromNames As String, Message As String) As Boolean
   
    Dim ToName() As Byte
    Dim FromName() As Byte
    Dim MessageToSend() As Byte
   
    'Put data into byte arrays
    ToName = UserOrMachine & vbNullChar
    FromName = FromNames & vbNullChar
    MessageToSend = Message & vbNullChar
   
    'Broadcast message via API
    If NetMessageBufferSend(ByVal 0&, ToName(0), ByVal 0&, _
    FromName(0), UBound(MessageToSend)) = NERR_Success Then
        'Return True if it worked
        BroadcastMessage = True
    End If

End Function
This is how to call the above function.

Dim blnMessageSent As Boolean
Dim strMessage As String
Dim strDestination As String

strMessage = "Hello"
strDestination = "Your_Dest_Comp"

blnMessageSent = BroadcastMessage(strDestination, Trim$(strMessage), String$(Len(Trim$(strMessage)), Space$(1)))
If Not blnMessageSent Then
     MsgBox "Message Not Sent"
End If

hongjun
Avatar of calahanpat
calahanpat

ASKER

Thanks! Exactly what I was looking for!Simple and to the point!