System.Text.Encoding.ASCII not declared
Hi,
I've used a sample code to create an RS232 connection in my application.
My problem is with this line:
m_CommPort.Write(Encoding.ASCII.GetBytes(Me.cbGPSSentence.Text & Chr(13)))
The Encoding (underlined) is coming up as undeclared. I know where the namespace is, but not too sure how to declare it?
It works fine without any visible declaration in the original app.
Any pointers?
Thanks
Re: System.Text.Encoding.ASCII not declared
Encoding is in the Text namespace (which is off of system)
You really answered your own question in your thread title..
simply use "System.Text.Encoding.ASCII" and not just "Encoding.ASCII"
If you want to shorten your code a bit, you can use an imports at the very top (above the class declaration)
VB Code:
'at top
Imports System.Text.Encoding
'in code
m_CommPort.Write(ASCII.GetBytes(Me.cbGPSSentence.Text & Chr(13)))
Re: System.Text.Encoding.ASCII not declared
Hmm, I tried importing it at the top but that didn't work.
But your method did work (I'm sure I read that somewhere before too - I'm such an idiot!)
Cheers