krafg
krafg

Reputation: 11

Line break problems in Visual Basic

My problem is that I need only ONE break line and when I run the program, it "magically" create one additional (I not know of where is in the code)

I have the following:

NotifyIcon1.Text = "Arduino Sensor Monitor" & vbCrLf & dato & "ºC"

when dato is a variable.

And it's resulting in:

https://i.imgur.com/kuxE5Mb.png

I know that vbCrLf is to do the break line, but I not know why create multiple line breaks when I put it one ONE TIME.

Upvotes: 0

Views: 180

Answers (1)

Anis R.
Anis R.

Reputation: 6902

As it is, your code

NotifyIcon1.Text = "Arduino Sensor Monitor" & vbCrLf & dato & "ºC"

does the following:

Taking the string "Arduino Sensor Monitor", adding a new line to it, then the content of the dato variable, and finally concatenating "ºC" to that, without any added line break.

So, as & should not add a line break, my guess is that your dato variable does include a line break. If so, using Replace should do the trick:

dato = Replace(dato, vbCrLf, "") 'removing line breaks in dato
NotifyIcon1.Text = "Arduino Sensor Monitor" & vbCrLf & dato & "ºC"

Upvotes: 1

Related Questions