vb.net - Display sensor value from Arduino using VB .NET -
i trying create application display moisture sensor value arduino using vb .net. display sensor value in label1.text seems doesn't show correct value.
i tried display values richtextbox , display correct value. example, if reading values 1023, value displayed in richtextbox1 1023 in label1 23, or 023, or 3.
any this?
private sub serialport1_datareceived(byval sender system.object, byval e system.io.ports.serialdatareceivedeventargs) handles serialport1.datareceived receivedtext(serialport1.readexisting()) end sub private sub receivedtext(byval [text] string) if me.richtextbox1.invokerequired dim x new settextcallback(addressof receivedtext) me.invoke(x, new object() {(text)}) else richtextbox1.text &= [text] label1.text = val([text]) end if end sub
why using val
set text
property of label1
?
val
returns numbers contained in string numeric value , stops reading string @ first character cannot recognize part of number.
e.g:
dim valresult double ' following line of code sets valresult 2457. valresult = val("2457") ' following line of code sets valresult 2457. valresult = val(" 2 45 7") ' following line of code sets valresult 24. valresult = val("24 , 57")
if receiving read value string...
label1.text = text
Comments
Post a Comment