|
-
Jan 24th, 2006, 09:43 AM
#1
Thread Starter
Junior Member
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
-
Jan 24th, 2006, 09:52 AM
#2
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)))
-
Jan 24th, 2006, 09:59 AM
#3
Thread Starter
Junior Member
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|