GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 24-Dec-2005, 05:53
harry.net harry.net is offline
New Member
 
Join Date: Oct 2005
Posts: 5
harry.net is on a distinguished road

Code for receiving data from parallel port in VB.net


Hi friends,

We have a project that we are going to recive information from the sensors which are connected to the parallel port , our application is developed by VB.net and SQL database.
how we are able to read from parallel port with vb.net?what is the code?and how we can store these data into our SQL database which is used in our vb.net application.actually we want our database to be updated by the information of the sensors.

Here I have a sample of reading information from parallel port in VB 6.
but my application is in vb.net

regards.

VB / Visual Basic Code:
' Change one bit in the control register.
Private Sub ControlCheck_Click ( Index As Integer )
  If Self Then Exit Sub
  Dim register As Byte
  register = Inp ( PortAddress + 2 )
  register = register Xor 2 ^ Index
  Out PortAddress + 2, register
End Sub

' Change one bit in the data register.
Private Sub DataCheck_Click ( Index As Integer )
  If Self Then Exit Sub
  If ControlCheck ( 5 ).Value = 1 Then Beep
  Dim register As Byte
  register = Inp ( PortAddress )
  register = register Xor 2 ^ Index
  Out PortAddress, register
End Sub

' Changes to the feedback register are impossible.
Private Sub FeedCheck_Click ( Index As Integer )
  If Not Self Then Beep
End Sub

' Start on parallel port #1.
Private Sub Form_Load ()
  PortSelect(0).Value = True
End Sub

' Scan all three registers and update the display.
' Repeat ten times a second.
Private Sub Poll_Timer ()
  Dim register As Byte
  Dim i As Byte
  Self = True ' avoid recursive changes
  ' Read data register
  register = Inp ( PortAddress )
  For i = 0 To 7
    If register And 2 ^ i Then
      DataCheck ( i ).Value = 1
    Else
      DataCheck ( i ).Value = 0
    End If
  Next i
  ' Read feedback register
  register = Inp ( PortAddress + 1 )
  For i = 3 To 7
    If register And 2 ^ i Then
      FeedCheck ( i ).Value = 1
    Else
      FeedCheck ( i ).Value = 0
    End If
  Next i
  ' Read control register
  register = Inp ( PortAddress + 2 )
  For i = 0 To 5
    If register And 2 ^ i Then
      ControlCheck ( i ).Value = 1
    Else
      ControlCheck ( i ).Value = 0
    End If
  Next i
  Self = False
End Sub

' Change the parallel port.
Private Sub PortSelect_Click ( Index As Integer )
  Select Case Index
  Case 0
    PortAddress = &H3BC
  Case 1
    PortAddress = &H378
  Case 2
    PortAddress = &H278
  End Select
End Sub
Last edited by admin : 24-Dec-2005 at 06:00. Reason: Please insert your VB code between [vb] & [/vb] tags
  #2  
Old 10-Mar-2006, 16:41
WebD WebD is offline
New Member
 
Join Date: Mar 2006
Posts: 19
WebD is on a distinguished road

Re: Code for receiving data from parallel port in VB.net


I think that the best approach would be to create a Win32 component which accesses the parellel port, and a .net application which communicates with the win32 component. Does this make sense?
 
 

Recent GIDBlogToyota - 2009 May Promotion by Nihal

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Doubly-linked List dsmith C Programming Language 6 14-Apr-2006 14:12
Strange C++ code memory leakage problem gaoanyu C++ Forum 7 04-Nov-2005 09:09
Send and receive data through port using MFC Dialog Based mithila MS Visual C++ / MFC Forum 1 10-Sep-2004 03:01
[CONTEST?]Data Structure Test dsmith C Programming Language 2 06-Jun-2004 16:13

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 18:09.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.