i need to develop a software in which i can connect to a handpunch1000 throug vb.net and collect data , i am using visual studio 2010 any help ?

4 Years
Discussion Span
Last Post by oussama_1

add a serialport to your form select your handpuch port

SerialPort1.PortName = ComboBox1.SelectedItem.ToString

open it


Receive data and convert

Private Sub DataReceived(ByVal sender As Object, _
                      ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) _
                      Handles SerialPort1.DataReceived
        If SerialPort1.BytesToRead > 0 Then
        SerialPort1.Read(your data)
        end if
        'convert bytes to plain text
        System.Text.Encoding.ASCII.GetString(your data)

good luck


what you mean by your data , can you give me an example ? if i want to collect a txt file from the handpunch , one more thing the hand punch is connected ethernet throug a converter from serial to network

Edited by elie.karkafy


your data: the data received from handpunch

        If SerialPort1.BytesToRead > 0 Then
            Dim buff(SerialPort1.BytesToRead - 1) As Byte
            SerialPort1.Read(buff, 0, buff.Length)
            Me.BeginInvoke(New myDelegate(AddressOf SerialPortDelegate), buff)
        End If

  Public Delegate Sub myDelegate(ByVal buff() As Byte)

   RichTextBox1.Text = System.Text.Encoding.ASCII.GetString(buff, 0, buff.Length)
            RichTextBox1.SaveFile("your path\filename.txt", RichTextBoxStreamType.PlainText)

Edited by oussama_1


dunno oussama run this code i am confused a little , my handpunch is connected to a converter that have an ip ( , i want to collect the data from my hand punct throug network

Edited by elie.karkafy


oh! ok try this

 Dim handpunchdata As String = New System.Net.WebClient().DownloadString(ip)

if that doesn't work i need to see a sample of your data (i mean is it a binary or hex...)


you remmenber the txt file i showed you for the import issue ? this txt file exported through a software that can connect to the handpunch , but i am trying to develop a similar software in vb

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.