read from LAN

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bryan

    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



  • MooVBuff

    #2
    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 WNetAddConnecti on Lib "mpr.dll" Alias "WNetAddConnect ionA"
    (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal
    lpszLocalName As String) As Long
    Declare Function WNetCancelConne ction Lib "mpr.dll" Alias
    "WNetCancelConn ectionA" (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(M yShareName As String, MyPWD As String, UseLetter As
    String) As Integer
    On Local Error GoTo AddConnection1_ Err
    AddConnection = WNetAddConnecti on(MyShareName, MyPWD, UseLetter)
    AddConnection_E nd:
    Exit Function
    AddConnection_E rr:
    AddConnection = Err
    MsgBox Error$
    Resume AddConnection_E nd
    End Function

    Function CancelConnectio n(DriveLetter As String, Force As Integer) As
    Integer
    On Local Error GoTo CancelConnectio n_Err
    CancelConnectio n = WNetCancelConne ction(DriveLett er, Force)
    CancelConnectio n_End:
    Exit Function
    CancelConnectio n_Err:
    CancelConnectio n = Err
    MsgBox Error$
    Resume CancelConnectio n_End

    End Function

    4. to add a connection call by:

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

    To cancel a connection type

    variable = CancelConnectio n(<SharePath, <Force>)

    5. Run the project.


    "Bryan" <kellyb@ieee.sp amnot.org> wrote in message
    news:pKJeb.5019 3$Ci5.1606110@t wister.tampabay .rr.com...[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]


    Comment

    • Steve Gerrard

      #3
      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.sp amnot.org> wrote in message
      news:pKJeb.5019 3$Ci5.1606110@t wister.tampabay .rr.com...[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]


      Comment

      • Bryan

        #4
        Re: read from LAN


        "Steve Gerrard" <notstevegerrar d@comcast.net> wrote in message
        news:BVydnaRq8J-pOeaiU-KYvw@comcast.co m...[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



        Comment

        • Bryan

          #5
          Re: read from LAN


          "MooVBuff" <edoepke@comcas t.net> wrote in message
          news:LcucneJSlu u98OaiU-KYiQ@comcast.co m...[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



          Comment

          • Steve Gerrard

            #6
            Re: read from LAN


            "Bryan" <kellyb@ieee.sp amnot.org> wrote in message
            news:Zq0fb.3858 2$Of2.1812179@t wister.tampabay .rr.com...[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.



            Comment

            Working...