Question: ChrW in VB.NET

  • Thread starter Thread starter VB Programmer
  • Start date Start date
V

VB Programmer

I have a line of code in my project: mobjText.Append(ChrW(Bytes(iIndex)))

I took out the reference to Microsoft.VisualBasic in my imports so that I am
forced to use all VB.NET stuff.

What is the replacement for the ChrW function?

Thanks,
Robert
 
VB Programmer,
The easiest way is to use ChrW!
Huh? I hope you realize that Microsoft.VisualBasic is VB.NET, as the VB in
VB.NET stands for Visual Basic. ;-)

If you meant "forced to use all .NET stuff", I hope you realize that
Microsoft.VisualBasic is native .NET stuff also! As I've mentioned earlier
there are items in Microsoft.VisualBasic that makes your live easier, there
are things that "should" be avoided, I question banning the entire Assembly!

You can use Convert.ToChar to convert a byte to a char without encoding.

If you need encoding you will need to use the System.Text.Encoding class.

Hope this helps
Jay
 
Hi Guys,
Boy I sure hate typing in Microsoft.VisualBasic.Whatever. They got rid of
some of that in VB 2003, but it's still required for some commands. If MS
would pull their heads out of their asses they'd make a compiler that would
try substituting Microsoft.VisualBasic.SomeCommand before giving up on
"SomeCommand" by itself.
Cheers,
Christian


Jay B. Harlow said:
VB Programmer,
The easiest way is to use ChrW!
that
Huh? I hope you realize that Microsoft.VisualBasic is VB.NET, as the VB in
VB.NET stands for Visual Basic. ;-)

If you meant "forced to use all .NET stuff", I hope you realize that
Microsoft.VisualBasic is native .NET stuff also! As I've mentioned earlier
there are items in Microsoft.VisualBasic that makes your live easier, there
are things that "should" be avoided, I question banning the entire Assembly!

You can use Convert.ToChar to convert a byte to a char without encoding.

If you need encoding you will need to use the System.Text.Encoding class.

Hope this helps
Jay

VB Programmer said:
I could use Microsoft.VisualBasic.ChrW, but is there another way?
that
 
Christian,
Huh? :-|
try substituting Microsoft.VisualBasic.SomeCommand before giving up on
"SomeCommand" by itself.
VB.NET 2002 & VB.NET 2003 already supports this:

Be certain to include "Imports Microsoft.VisualBasic" at the top of your
source file, then you can use Whatever directly. I normally use Whatever
directly! I normally let Microsoft.VisualBasic be imported under Project
Properties, so I do not need to include it in each source file. (Note using
Project Imports in itself is a debatable practice, which I neither endorse
nor oppose).

Not that I use Strings.Left & Strings.Right, but if I were to use them on a
Form I would use VB.Left & VB.Right, where first I did a import alias:

Imports VB = Microsoft.VisualBasic

VB.Whatever

As Left & Right are already properties of Control, so the properties get
precedence.

Hope this helps
Jay
 
Hello,

Christian Blackburn said:
Boy I sure hate typing in Microsoft.VisualBasic.Whatever.
They got rid of some of that in VB 2003, but it's still required for
some commands. If MS would pull their heads out of their asses
they'd make a compiler that would try substituting Microsoft.
VisualBasic.SomeCommand before giving up on
"SomeCommand" by itself.

In VB.NET projects, the namespace 'Microsoft.VisualBasic' gets imported
automatically (project imports). You don't need to Type
'Microsoft.VisualBasic.Strings.Left', only type 'Strings.Left' and so on.
 
Back
Top