Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My code

how can i write code
please help me anybody

What I have tried:

Public Class Form1
    Dim SerialPort1 As IO.Ports.SerialPort


    Delegate Sub SetTextCallback(ByVal data As String)

    Private Delegate Sub UpdateLabelDelegate(theText As String)
    Private Sub UpdateLabel(theText As String)
        If Me.InvokeRequired Then
            Me.Invoke(New UpdateLabelDelegate(AddressOf UpdateLabel), theText)
        Else
            TextBox1.Text = theText
        End If
    End Sub

    Private Sub SerialPort1_DataReceived(ByVal sender As System.Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Dim returnStr As String
        returnStr = SerialPort1.ReadExisting
        Me.BeginInvoke(Sub()

                           UpdateLabel(returnStr)
                       End Sub)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        SerialPort1.Open()

    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        SerialPort1.Close()
    End Sub
End Class
Posted
Updated 28-Aug-22 20:55pm

You should read the documentation of the device and implement the specified protocol.
Without knowing more details, we cannot give better help.
 
Share this answer
 
Comments
OriginalGriff 29-Aug-22 2:55am    
:thumbsup:
To add to what Carlo has - correctly - said ...

Don't start by writing code - there are far too many things which can trip you up, and if you throw together code to see if it works, you have no idea why it failed if it doesn't work immediately.
Instead, start with something like Hyperterminal, and get communications established (using the manufacturers info to establish the connection). Once you get two way communications that you understand working there, move to code, and get exactly the same thing working in a tiny program. When that works, you can start building a "real world" app which uses the working code as a base.
 
Share this answer
 
Comments
CPallini 29-Aug-22 2:57am    
5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900