0

I seem to be having some trouble sending Data to the connected Socket.

I'm quite new to programming so Sorry if my terms aren't 100% correct.

The problem is if I use:

Public Function send()
    Dim s As Byte() = Encoding.ASCII.GetBytes(Form1.TextBox4.Text)
    TL2.Send(s)
End function

I get a

System.NullReferenceException.

I'm looking forward to your help!

with kind regards.

R4z0r

Edit: I tought i was using the wrong method to convert string to bytes.. Like i said before im quite new to the code world. so please to flag me for weird stuff like "Duplicate posts"

R4z0rl43g3
  • 25
  • 5
  • One of those variable is null, you should start by looking at that. Maybe TL2 isn't initialized? – the_lotus Jul 25 '18 at 12:58
  • @the_lotus You and PavlinII Are right, Thanks a bunch! – R4z0rl43g3 Jul 25 '18 at 13:05
  • 1
    Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – A Friend Jul 25 '18 at 13:29

1 Answers1

0

That depends on the line of code. If it's the first list (less propable) than your Form1 is nothing and you can't get .Textbox4 value. If your Send is inside Form1 than remove Form1.

Othwerwite your problem is that TL2 is Nothing and is not connected nor initialized.

PavlinII
  • 1,061
  • 1
  • 7
  • 12