Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 09:06 PM
Bryan
Guest
 
Posts: n/a
Default read from LAN

Can anyone give me a code fragment in visual basic that will read from a
device on my LAN?

I looked in several books at B&N and found nothing.
I posted this question two days ago and received absolutely no response.
This is a visual basic forum and my question is visual basic. Is there
maybe something else wrong with my post?

Thanks for your time,
Bryan



  #2  
Old July 17th, 2005, 09:06 PM
MooVBuff
Guest
 
Posts: n/a
Default Re: read from LAN

It may be because no-one has an answer. Here is a snippet of an article I
found that should setup a mapped connection using VB. I haven't tried it but
I hope it may help.

[Article]

This can be easily done by using map network drive in Network Neighbourhood
or My Computer but it can be useful to be able to do this in Visual Basic. I
had a letter asking whether this was possible doing Send Keys (A beginners
response), but I will now show you how to do this using Windows API

Here is the example: Also includes how to delete a connection

1. Start a new Standard-EXE project, form1 is created by default

2. Add a standard module and add a command button to form1

3. Type the following in the standard module. NB.

Option Explicit
Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA"
(ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal
lpszLocalName As String) As Long
Declare Function WNetCancelConnection Lib "mpr.dll" Alias
"WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As
Long
Const WN_SUCCESS = 0 ' The function was successful.
Const WN_NET_ERROR = 2 ' An error occurred on the network.
Const WN_BAD_PASSWORD = 6 ' The password was invalid.

Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As
String) As Integer
On Local Error GoTo AddConnection1_Err
AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
AddConnection_End:
Exit Function
AddConnection_Err:
AddConnection = Err
MsgBox Error$
Resume AddConnection_End
End Function

Function CancelConnection(DriveLetter As String, Force As Integer) As
Integer
On Local Error GoTo CancelConnection_Err
CancelConnection = WNetCancelConnection(DriveLetter, Force)
CancelConnection_End:
Exit Function
CancelConnection_Err:
CancelConnection = Err
MsgBox Error$
Resume CancelConnection_End

End Function

4. to add a connection call by:

variable = AddConnection(<SharePath>, <Password>, <DriveLetter>)

To cancel a connection type

variable = CancelConnection(<SharePath, <Force>)

5. Run the project.


"Bryan" <kellyb@ieee.spamnot.org> wrote in message
news:pKJeb.50193$Ci5.1606110@twister.tampabay.rr.c om...[color=blue]
> Can anyone give me a code fragment in visual basic that will read from a
> device on my LAN?
>
> I looked in several books at B&N and found nothing.
> I posted this question two days ago and received absolutely no response.
> This is a visual basic forum and my question is visual basic. Is there
> maybe something else wrong with my post?
>
> Thanks for your time,
> Bryan
>
>
>[/color]


  #3  
Old July 17th, 2005, 09:06 PM
Steve Gerrard
Guest
 
Posts: n/a
Default Re: read from LAN

Start with the Microsoft WinSock control. Perhaps you can setup a windows
socket, and establish a TCP or UDP connection to your "Rabbit". In general,
network connections and device drivers are very detailed and specific, which is
why you are not getting much response.

"Bryan" <kellyb@ieee.spamnot.org> wrote in message
news:pKJeb.50193$Ci5.1606110@twister.tampabay.rr.c om...[color=blue]
> Can anyone give me a code fragment in visual basic that will read from a
> device on my LAN?
>
> I looked in several books at B&N and found nothing.
> I posted this question two days ago and received absolutely no response.
> This is a visual basic forum and my question is visual basic. Is there
> maybe something else wrong with my post?
>
> Thanks for your time,
> Bryan
>
>
>[/color]


  #4  
Old July 17th, 2005, 09:06 PM
Bryan
Guest
 
Posts: n/a
Default Re: read from LAN


"Steve Gerrard" <notstevegerrard@comcast.net> wrote in message
news:BVydnaRq8J-pOeaiU-KYvw@comcast.com...[color=blue]
> Start with the Microsoft WinSock control. Perhaps you can setup a windows
> socket, and establish a TCP or UDP connection to your "Rabbit". In[/color]
general,[color=blue]
> network connections and device drivers are very detailed and specific,[/color]
which is[color=blue]
> why you are not getting much response.[/color]
<snip>

The Rabbit end of this is not going to be a problem, its the PC end where I
need to make the standard calls to access the data from the Rabbit. I have
the details for the Rabbit, but nothing about using the network within the
Visual Basic environment. The lacking of details within Basic is the part
that really suprised me.

Thanks for your time and your response,
Bryan



  #5  
Old July 17th, 2005, 09:06 PM
Bryan
Guest
 
Posts: n/a
Default Re: read from LAN


"MooVBuff" <edoepke@comcast.net> wrote in message
news:LcucneJSluu98OaiU-KYiQ@comcast.com...[color=blue]
> It may be because no-one has an answer. Here is a snippet of an article I
> found that should setup a mapped connection using VB. I haven't tried it[/color]
but[color=blue]
> I hope it may help.
>[/color]
<snip>

That is a completely valid response, but completely unexpected. In today's
world of connectivity I expected that network communications would be a
standard of almost every language. I found a Microsoft book of Visual Basic
with the install disk for about $25 or so. For the comfort of having a
hardcopy manual the cost is justified. The problem was that I found nothing
about networks and was quite puzzled.

So my action now seems to be to purchase the manual, install Visual Basic,
and work with the code you have given me.

Thanks for your time,
Bryan



  #6  
Old July 17th, 2005, 09:06 PM
Steve Gerrard
Guest
 
Posts: n/a
Default Re: read from LAN


"Bryan" <kellyb@ieee.spamnot.org> wrote in message
news:Zq0fb.38582$Of2.1812179@twister.tampabay.rr.c om...[color=blue]
>
>
> The Rabbit end of this is not going to be a problem, its the PC end where I
> need to make the standard calls to access the data from the Rabbit. I have
> the details for the Rabbit, but nothing about using the network within the
> Visual Basic environment. The lacking of details within Basic is the part
> that really suprised me.
>
> Thanks for your time and your response,
> Bryan
>[/color]

Most interaction with the "outside world" in VB (besides keyboard, mouse, and
files) is handled through API calls to Windows, or with controls and DLLs. You
may not find much in some books, because they are focused on the "internal"
language. If you search for Windows API books or web pages, you can find all
sorts of stuff.



 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.