# UDP Data to Variables

**URL:** <https://forum.arduino.cc/t/udp-data-to-variables/1056881>\
**Category:** General Guidance\
**Created:** [November 22, 2022, 8:35pm UTC](https://forum.arduino.cc/t/udp-data-to-variables/1056881 "2022-11-22T20:35:33Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![horace](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/horace/32/1014299_2.png) [@horace](https://forum.arduino.cc/u/horace)\
**Post date:** [November 22, 2022, 9:07pm UTC](https://forum.arduino.cc/t/udp-data-to-variables/1056881/2 "2022-11-22T21:07:25Z")

</div>

have a look at [Serial input basics](https://forum.arduino.cc/t/serial-input-basics-updated/382007) section on _Receiving numbers rather than text_ and [parseInt()](https://www.arduino.cc/reference/en/language/functions/communication/serial/parseint/)

you could use sscanf(), e.g.

```cpp
void setup() {
  Serial.begin(115200);
  while(!Serial.available()); // wait for data
  char data[100]={0};
  Serial.readBytesUntil('\n',data,100); 
  int i,j;
  // find last space in string convert two integers
  if(sscanf(strrchr(data, ' '),"%d,%d", &i, &j)==2){
    Serial.println(i);
    Serial.println(j);
  }
}

void loop() {}
```

when run using serial monitor input "Remote IP: 192.168.111.168 50155 15000,8882" output was

```cpp
05:17:58.916 -> 15000
05:17:58.916 -> 8882

```

are you planning to connect your VB program to the COM port normally used by the Serial Monitor or use a seperate COM port?

---

_[View the full topic](https://forum.arduino.cc/t/udp-data-to-variables/1056881)._
