How to use NET SEND Command from Form Click Event

  • Thread starter Thread starter Irshad Alam
  • Start date Start date
I

Irshad Alam

Note : I posted the same question earlier on 08/08/2008, found no reply.
Please advise on below, it will help me to solve the issue

ORIGINAL EARLIER MESSAGE:

I would like to send message to a particular IP Address the message at a
time, the details of my requirement is as below

My Form Name : SendMsgForm
Fields are :
ComboIPAd (combo box having the IP address to be send)
MsgForDel (Text box having the message to be send)
MsgDelConfirm : (Yes/No Field - should be ticked, if send)

JOBS I WANTED TO BE DONE IS :
Once the button is clicked on the form, the following to be done :

First check if my PC is connected to the network
If connected proceed and if not connected then cancel the event
During proceed it should collect the IP Address from combo and message from
text field
confirm by ticking the yes/no field if msg delivered.

Please advice me a code with some tips, as I am not very good in VBA.

I am using Windows Xp service Pack II and MS office 2000

Thanking you all in advance

Regards

Irshad
 
you might be able to adapt some of the code found at http://vbnet.mvps.org

for instance
http://vbnet.mvps.org/index.html?code/network/mailslotbroadcast.htm looks
promising to send messages

and you could use
http://vbnet.mvps.org/index.html?code/network/isnetworkalive.htm to check
your network connection state.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
Irshad Alam said:
Note : I posted the same question earlier on 08/08/2008, found no reply.
Please advise on below, it will help me to solve the issue

ORIGINAL EARLIER MESSAGE:

I would like to send message to a particular IP Address the message at a
time, the details of my requirement is as below

My Form Name : SendMsgForm
Fields are :
ComboIPAd (combo box having the IP address to be send)
MsgForDel (Text box having the message to be send)
MsgDelConfirm : (Yes/No Field - should be ticked, if send)

JOBS I WANTED TO BE DONE IS :
Once the button is clicked on the form, the following to be done :

First check if my PC is connected to the network
If connected proceed and if not connected then cancel the event
During proceed it should collect the IP Address from combo and message
from
text field
confirm by ticking the yes/no field if msg delivered.

Please advice me a code with some tips, as I am not very good in VBA.

I am using Windows Xp service Pack II and MS office 2000

Thanking you all in advance

Regards

Irshad

Further to Daniel's suggestions, here's another you can try:

http://www.smccall.demon.co.uk/MiscApi.htm#Netsend
 
Gentlemen,
Thank you so much for your advise.

The following worked after few modification to the original code, which
suited my need. The code I am posting here, if any reader following it:

Option Compare Database

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2008 VBnet, Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Const NETWORK_ALIVE_LAN = &H1 'net card connection
Private Const NETWORK_ALIVE_WAN = &H2 'RAS connection
Private Const NETWORK_ALIVE_AOL = &H4 'AOL

Private Declare Function IsNetworkAlive Lib "Sensapi" _
(lpdwFlags As Long) As Long



Private Sub Command1_Click()

Me.Text1 = IsNetConnectionLAN()
Me.Text2 = IsNetConnectionRAS()
Me.Text3 = IsNetConnectionAOL()
Me.Text4 = IsNetConnectionAlive()
Me.Text5 = GetNetConnectionType()
End Sub


Private Function IsNetConnectionAlive() As Boolean

Dim tmp As Long
IsNetConnectionAlive = IsNetworkAlive(tmp) = 1

End Function


Private Function IsNetConnectionLAN() As Boolean

Dim tmp As Long

If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionLAN = tmp = NETWORK_ALIVE_LAN
End If

End Function


Private Function IsNetConnectionRAS() As Boolean

Dim tmp As Long

If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionRAS = tmp = NETWORK_ALIVE_WAN
End If

End Function


Private Function IsNetConnectionAOL() As Boolean

Dim tmp As Long

If IsNetworkAlive(tmp) = 1 Then
IsNetConnectionAOL = tmp = NETWORK_ALIVE_AOL
End If

End Function


Private Function GetNetConnectionType() As String

Dim tmp As Long

If IsNetworkAlive(tmp) = 1 Then

Select Case tmp
Case NETWORK_ALIVE_LAN:
GetNetConnectionType = _
"The system has one or more active LAN cards"
Case NETWORK_ALIVE_WAN:
GetNetConnectionType = _
"The system has one or more active RAS connections"
Case NETWORK_ALIVE_AOL:
GetNetConnectionType = _
"The system is connected to America Online"
Case Else
End Select

Else

GetNetConnectionType = _
"The system has no connection or an error occurred"

End If

End Function




Private Sub Command22_Click()

Dim sendip As Variant
Dim sendtxt As Variant

sendip = Me.Combo25
sendtxt = Me.Text23

If Me.Text4 = "True" Then
Shell ("NET SEND " & sendip & " " & sendtxt)
MsgBox "Message has been sent sucessfully!!"
Else
MsgBox "Error !!!!, Your Network is working or not connected, It cannot be
send", vbCritical, "IrshadErrorDailog"
End If

End Sub

'----------

Regards

Irshad
 
Back
Top