473,509 Members | 12,711 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Jul 17 '05 #1
5 4066
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" <ke****@ieee.spamnot.org> wrote in message
news:pK*********************@twister.tampabay.rr.c om...
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

Jul 17 '05 #2
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" <ke****@ieee.spamnot.org> wrote in message
news:pK*********************@twister.tampabay.rr.c om...
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

Jul 17 '05 #3

"Steve Gerrard" <no*************@comcast.net> wrote in message
news:BV********************@comcast.com...
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.

<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

Jul 17 '05 #4

"MooVBuff" <ed*****@comcast.net> wrote in message
news:Lc********************@comcast.com...
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.

<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

Jul 17 '05 #5

"Bryan" <ke****@ieee.spamnot.org> wrote in message
news:Zq*********************@twister.tampabay.rr.c om...


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


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.

Jul 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
8970
by: Gunnar | last post by:
Hello, I've just written a CPP program that reads integers from a binary file, and used this code while (my_ifstram.read( (char* ) &number, sizeof(int)) { // do something with number } My...
11
12660
by: Markus Breuer | last post by:
I have a question about oracle commit and transactions. Following scenario: Process A performs a single sql-INSERT into a table and commits the transaction. Then he informs process B (ipc) to...
12
11631
by: Steven T. Hatton | last post by:
I know of a least one person who believes std::ifstream::read() and std::ofstream::write() are "mistakes". They seem to do the job I want done. What's wrong with them. This is the code I...
2
3069
by: Sandman | last post by:
Just looking for suggestion on how to do this in my Web application. The goal is to keep track of what a user has and hasn't read and present him or her with new material I am currently doing...
4
3834
by: Ollie Cook | last post by:
Hi, I am having some difficulty with read(2) and interrupting signals. I expect I am misunderstanding how the two work together, so would appreciate some guidance. I am trying to 'time out' a...
6
2651
by: BBM | last post by:
I have an object that has a fairly complex construction sequence, so I have written a dedicated "factory" class that invokes the constructor of my object class (which does nothing but instantiate...
8
23886
by: a | last post by:
I have a struct to write to a file struct _structA{ long x; int y; float z; } struct _structA A; //file open write(fd,A,sizeof(_structA)); //file close
1
3979
by: Jose Reckoner | last post by:
I'm running python 2.3 on Windows XP. Anyone have a quick small script to convert .DT1 and .DEM data to ASCII or some other format? I don't need a viewer. Thanks!
0
4696
by: phplasma | last post by:
Hey, I am currently attempting to implement a multi-threaded C# socket, using SSL (.pem file/certification/private key combo) server using Visual Studio C# Express. I have successfully made...
6
5685
by: arnuld | last post by:
This works fine, I welcome any views/advices/coding-practices :) /* C++ Primer - 4/e * * Exercise 8.9 * STATEMENT: * write a program to store each line from a file into a *...
0
7137
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7349
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.