B4J Question Text Area String to Array of Objects to send with UDP - Solved

KiloBravo

Active Member
Licensed User
B4J program sending UDP Packets to ESP32
This works fine ...

Static Objects:
    Dim pktStart As Object = "<"
    Dim x As Object = Rnd(0,255)
    Dim y As Object = Rnd(0,255)
    Dim some_string As Object = "string"
    Dim pktEnd As Object = ">"
    Dim send_data(5) As Object
    send_data(0) = pktStart
    send_data(1) = x
    send_data(2) = y
    send_data(3) = some_string
    send_data(4) = pktEnd
    UDP_SendPacket(serz.ConvertArrayToBytes(send_data))

I want to take a string of alphanumeric characters from a text area and send them as objects to the esp32
Dim mySTR As String = TextArea1.Text <<< so the text are might contain a string like "123 789 test !@#"

So how do I convert that string to an array of objects so I can send it with this line of code ?
UDP_SendPacket(serz.ConvertArrayToBytes(send_data))

I have searched and tried a bunch of different code but can not getting it working correctly.

Thanks!
 

KiloBravo

Active Member
Licensed User
Well I figured out the problem. It was with B4J as usual! :eek:

Erel just makes everything to easy! LOL !!! ?

Simple once you know how !:
    Dim mySTR() As String = Regex.Split(" ",TextArea3.Text)
    Dim send_data () As Object = mySTR
    UDP_SendPacket(serz.ConvertArrayToBytes(send_data))
 
Upvote 0
Top