Help with my Serial Port Code

earvinnill

New member
Joined
Aug 16, 2016
Messages
4
Programming Experience
5-10
I'm having a problem about closing the port, because everytime i close the port, my program freezes.

VB.NET:
 Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click, Button2.TextChanged, RichTextBox2.TextChanged
        Try
            If SerialPort1.IsOpen Then
                CloseComPort()
            End If
            RichTextBox1.Text = FormatNumber(CDbl(RichTextBox2.Text.ToString), 4)


            mysql.Open()
            Dim query As String = "INSERT into test.earvin (measure) VALUES ('" + RichTextBox2.Text + "')"
            Dim cmd As New MySqlCommand(query, mysql)
            cmd.ExecuteNonQuery()
            MsgBox("Connected")
            mysql.Close()






        Catch ex As Exception
            MsgBox(ex.Message)
        End Try


        RichTextBox2.Clear()
        RichTextBox1.Clear()




    End Sub
 
The example output of my data is: 2.434 but when I executed it, at first it becomes 2.434 but after the event click
the output become's a whole number and a different number. May I know how can I fixed it? Please help. Thank you very much!
 
Back
Top