Converting a string of times in vb

I have my Arduino sending 8 different times in a string to visual basic the times are in milliseconds but I want to convert to seconds to display them what's the best why to do this I was using time / 1000.0, 3 in the Arduino when I was sending them individually to the serial monitor but I can't get this to work when I send them in a string it always just displays a 3

does the serial mointor display what you expect? give an example

post the VB code?

        Dim timeString() As String

        timeString = myData.Split(New Char() {","c})
        reacL.Text = timeString(0)
        sixtyL.Text = timeString(1)
        mphL.Text = timeString(2)
        etL.Text = timeString(3)
        reacR.Text = timeString(4)
        sixtyR.Text = timeString(5)
        mphR.Text = timeString(6)
        etR.Text = timeString(7)/code]

I don't have all the VB code with me this is what I'm using now the mydata is coming in with a string of 8 times in milliseconds and I need to convert to Seconds

could you give an example of myData?
your StringSplit looks OK, e.g.

        Dim s As String = "data1,data2,data3"
        Dim words As String() = s.Split(New Char() {","c})
        Dim word As String
        For Each word In words
            Console.WriteLine(word)
        Next

gives

data1
data2
data3

Have you considered to print the individual times as seconds from your Arduino code?

You don't have to collect it in a String as you did in your other thread.

Serial.print(time1/1000, 3);
Serial.print(",");
Serial.print(time2/1000, 3);
...
...
Serial.println();

Your PC will not notice the difference.

The mydata is coming in like 2435,2654,6545,3233,4553,3214,3212,2533,
They are millisecond from a timer everything is working and display right but I need to change to seconds

I was using serialprint(data1 / 1000.0, 3)
In the Arduino and printing each data separate but when I started using the vb and I tried to convert all the data then put it in the string and send to vb but all it would send was a 3 so I changed it back to just send the milliseconds

are you looking for output along the lines of

       Dim s As String = "2435,2654,6545,3233,4553,3214,3212,2533"
        Dim words As String() = s.Split(New Char() {","c})
        Dim word As String
        For Each word In words
            Console.WriteLine(FormatNumber(word / 1000.0, 2))
        Next

gives

2.44
2.65
6.55
3.23
4.55
3.21
3.21
2.53

No I didn’t try that I will try that this afternoon when I print individual they would convert and sent

Also is there any way to other data to the vb using the same serial port maybe a different string and vb be able to tell the difference like I have a text box that all my serial data is printed to I can send serialprintln(“test) then my data and it come through on my text box

Test
23,34,45,43,32,11,56,83,

They were sent over at different time the test first then my data

And when it puts my data in the appropriate box my first box shows

Test
23
Can I make it ignore the text and just show my data or do I need to have everything print at once and split the text out in my string also

if you are transmitting different types of data at random you require a protocol, e.g. each line could start with a string indicating the data type

time,2435,2654,6545,3233,4553,3214,3212,2533
test,23,34,45,43,32,11,56,83

use String.Split examine the first element to determine the data type e.g.

        Dim s As String = "time,2435,2654,6545,3233,4553,3214,3212,2533"
        Dim words As String() = s.Split(New Char() {","c})
        If (String.Compare(words(0), "time") = 0) Then
            For i As Integer = 1 To words.Length - 1
                Console.WriteLine(FormatNumber(words(i) / 1000.0, 2))
            Next
        End If

Yes that’s what I’m looking for

Though out my Arduino program it will print Stuff to let me know what is going on like it will print go left or jump left go right or jump right I want all that to stay in my text box but pull my times to the appropriate box to display so would I just need to indicate my times with the protocol to be pulled from the text box and the rest will just print to the box

Yoy could print times to one textbox and the other output to a different textbox

I would like to do that but I no clue on how to or even where to start to right the code

horace:
are you looking for output along the lines of

       Dim s As String = "2435,2654,6545,3233,4553,3214,3212,2533"

Dim words As String() = s.Split(New Char() {","c})
        Dim word As String
        For Each word In words
            Console.WriteLine(FormatNumber(word / 1000.0, 2))
        Next



gives


2.44
2.65
6.55
3.23
4.55
3.21
3.21
2.53

i tried this but it was giving me System.InvalidCastException
HResult=0x80004002
Message=Conversion from string “” to type ‘Double’ is not valid.
Source=Microsoft.VisualBasic

this was my code

Imports System.IO.Ports
Public Class Form1
    Dim comPORT As String


    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        comPORT = ""
        For Each sp As String In My.Computer.Ports.SerialPortNames
            comPORT_comboBox.Items.Add(sp)
        Next

    End Sub

    Private Sub comPORT_comboBox_SelectedIndexChanged(sender As Object, e As EventArgs) Handles comPORT_comboBox.SelectedIndexChanged
        If (comPORT_comboBox.SelectedItem <> "") Then
            comPORT = comPORT_comboBox.SelectedItem
        End If
    End Sub

    Private Sub connect_Btn_Click(sender As Object, e As EventArgs) Handles connect_Btn.Click
        If (connect_Btn.Text = "Connect") Then
            If (comPORT <> "") Then
                SerialPort1.Close()
                SerialPort1.PortName = comPORT
                SerialPort1.BaudRate = 115200
                SerialPort1.DataBits = 8
                SerialPort1.Parity = Parity.None
                SerialPort1.StopBits = StopBits.One
                SerialPort1.Handshake = Handshake.None
                SerialPort1.Encoding = System.Text.Encoding.Default
                SerialPort1.ReadTimeout = 10000
                SerialPort1.Open()
                connect_Btn.Text = "Dis-connect"
            Else
                MsgBox("Select a COM Port First")
            End If
        Else
            SerialPort1.Close()
            connect_Btn.Text = "Connect"

        End If

    End Sub

    Private Sub BtnStart_Click(sender As Object, e As EventArgs) Handles BtnStart.Click
        If BtnIG.Checked = True Then
            SerialPort1.Write("I")
            TextBox1.Text = ""
        ElseIf BtnPT.Checked = True Then
            SerialPort1.Write("P")
            TextBox1.Text = ""
        ElseIf BtnST.Checked = True Then
            SerialPort1.Write("S")
            TextBox1.Text = ""
        End If
    End Sub



    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles ldisp.CheckedChanged
        If ldisp.Checked Then
            SerialPort1.Write("ld")
        Else
            SerialPort1.Write("LD")
        End If

    End Sub

    Private Sub rdisp_CheckedChanged(sender As Object, e As EventArgs) Handles rdisp.CheckedChanged
        If rdisp.Checked Then
            SerialPort1.Write("rd")
        Else
            SerialPort1.Write("RD")
        End If

    End Sub

    Private Sub DataReceived(ByVal sender As Object, ByVal e As SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
        Try
            Dim mydata As String
            mydata = SerialPort1.ReadLine()

            If TextBox1.InvokeRequired Then
                TextBox1.Invoke(DirectCast(Sub() TextBox1.Text &= mydata, MethodInvoker))
            Else
                TextBox1.Text &= mydata
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick

        Dim s As String

        s = TextBox1.Text + "," + "," + "," + "," + "," + "," + "," + "," + ""

        Dim timeStrings() As String = s.Split(New Char() {","c})
        Dim timeString As String
        For Each timeString In timeStrings
            Console.WriteLine(FormatNumber(timeString / 1000.0, 3))

            reacL.Text = timeString(0)
            sixtyL.Text = timeString(1)
            mphL.Text = timeString(2)
            etL.Text = timeString(3)
            reacR.Text = timeString(4)
            sixtyR.Text = timeString(5)
            mphR.Text = timeString(6)
            etR.Text = timeString(7)
        Next
    End Sub

End Class

you are probably using FormatNumber() to convert a String to Double which does not contant valid numeric data (in this case an empty string "")
try using Double.TryParse() which will tell you if the conversion fails, e.g.

        Dim s As String = "time,2435,2654,6545,3233,4553,3214,3212,2533"
        Dim words As String() = s.Split(New Char() {","c})
        If (String.Compare(words(0), "time") = 0) Then
            For i As Integer = 0 To words.Length - 1
                Dim value As Double
                If Double.TryParse(words(i), value) Then
                    Console.WriteLine(FormatNumber(words(i) / 1000.0, 2))
                Else
                    Console.WriteLine("Error! string '" + words(i) + "' is not a Double")
                End If
            Next
        End If

gives

Error! string 'time' is not a Double
2.44
2.65
6.55
3.23
4.55
3.21
3.21
2.53

attempting to convert the string time to a double fails and displays the error message

any reason why you analyse your data in a timer event handler rather than the serial data received event handler? also note you should not directly manipulate GUI components (such as a TextBox) in the serial event handler - it is not thread safe - use a delagate