By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,417 Members | 1,088 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,417 IT Pros & Developers. It's quick & easy.

converting int to char

P: n/a
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).

Thanks.

-Nikhil
Nov 20 '05 #1
Share this Question
Share on Google+
23 Replies


P: n/a
Nikhil.

did you try

char c = (char)13;

HTH
Alex

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).

Thanks.

-Nikhil

Nov 20 '05 #2

P: n/a
Thanks Alex,
Unfortunately I am using VB.Net not C#.

I tried

CType(10, Char)

in VB.Net. But it returned "1".
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Nikhil.

did you try

char c = (char)13;

HTH
Alex

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without using Microsoft.VisualBasic dll or any other dll(I want to reference only System.dll).

Thanks.

-Nikhil


Nov 20 '05 #3

P: n/a
Nikhil,
Have you looked at ChrW?

Dim ch As Char = ChrW(10)

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:uw**************@tk2msftngp13.phx.gbl...
Thanks Alex,
Unfortunately I am using VB.Net not C#.

I tried

CType(10, Char)

in VB.Net. But it returned "1".
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Nikhil.

did you try

char c = (char)13;

HTH
Alex

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without using Microsoft.VisualBasic dll or any other dll(I want to reference only System.dll).

Thanks.

-Nikhil



Nov 20 '05 #4

P: n/a
You fail to mention the Text Encoding used, so I will assume the Integer in
question already represents ASCII.
Here is just a couple of the available methods, there are more depending upon
encoding.

Dim intChar As Integer = 65 'ASCII "A"
Dim c As Char

c = Chr(intChar)
c = Convert.ToChar(intChar)

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).

Thanks.

-Nikhil

Nov 20 '05 #5

P: n/a
Thanks Jay.

The ChrW is in Microsoft.VisualBasic dll. I don't want to load this dll just
for this one function. Because my application is already very slow.

Is there any way to do this using only System.dll?

Thanks.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
Nikhil,
Have you looked at ChrW?

Dim ch As Char = ChrW(10)

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:uw**************@tk2msftngp13.phx.gbl...
Thanks Alex,
Unfortunately I am using VB.Net not C#.

I tried

CType(10, Char)

in VB.Net. But it returned "1".
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Nikhil.

did you try

char c = (char)13;

HTH
Alex

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
> Hi all,
> How can I convert an integer to its equivalent ascii character

without
> using Microsoft.VisualBasic dll or any other dll(I want to reference

only
> System.dll).
>
> Thanks.
>
> -Nikhil
>
>



Nov 20 '05 #6

P: n/a
Sorry, failed to notice the part about just System.dll
These are of course in the VisualBasic portion.

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
You fail to mention the Text Encoding used, so I will assume the Integer in
question already represents ASCII.
Here is just a couple of the available methods, there are more depending upon
encoding.

Dim intChar As Integer = 65 'ASCII "A"
Dim c As Char

c = Chr(intChar)
c = Convert.ToChar(intChar)

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).

Thanks.

-Nikhil


Nov 20 '05 #7

P: n/a
CableWizard,
Thanks. It worked.

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
You fail to mention the Text Encoding used, so I will assume the Integer in question already represents ASCII.
Here is just a couple of the available methods, there are more depending upon encoding.

Dim intChar As Integer = 65 'ASCII "A"
Dim c As Char

c = Chr(intChar)
c = Convert.ToChar(intChar)

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without using Microsoft.VisualBasic dll or any other dll(I want to reference only System.dll).

Thanks.

-Nikhil


Nov 20 '05 #8

P: n/a
use the Convert static class.

Dim X as integer = 70
Dim Y as Char = Convert.ToChar(X)

Telmo Sampaio

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).

Thanks.

-Nikhil

Nov 20 '05 #9

P: n/a
I am a little confused however.
You posted to the VB group, but don't want to include the Microsoft.VisualBasic
dll?
You really can't do anything without that.
If you are running the IDE with a VB project open, that is automatically
referenced, and won't even appear in the references.
Are you confusing this dll with the Compatibility dll?

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
CableWizard,
Thanks. It worked.

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
You fail to mention the Text Encoding used, so I will assume the Integer

in
question already represents ASCII.
Here is just a couple of the available methods, there are more depending

upon
encoding.

Dim intChar As Integer = 65 'ASCII "A"
Dim c As Char

c = Chr(intChar)
c = Convert.ToChar(intChar)

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi all,
How can I convert an integer to its equivalent ascii character without using Microsoft.VisualBasic dll or any other dll(I want to reference only System.dll).

Thanks.

-Nikhil



Nov 20 '05 #10

P: n/a
Nikhil,
ChrW(10) is a constant expression!

Microsoft.VisualBasic will not be loaded!

Which also means that ChrW(10) does it without either
Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).

Only time that ChrW needs to load Microsoft.VisualBasic is when the
parameter is non constant, such as a variable or property.

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Thanks Jay.

The ChrW is in Microsoft.VisualBasic dll. I don't want to load this dll just for this one function. Because my application is already very slow.

Is there any way to do this using only System.dll?

Thanks.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
Nikhil,
Have you looked at ChrW?

Dim ch As Char = ChrW(10)

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:uw**************@tk2msftngp13.phx.gbl...
Thanks Alex,
Unfortunately I am using VB.Net not C#.

I tried

CType(10, Char)

in VB.Net. But it returned "1".
"AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
> Nikhil.
>
> did you try
>
> char c = (char)13;
>
> HTH
> Alex
>
> "Nikhil Patel" <ni********@aol.com> wrote in message
> news:en**************@TK2MSFTNGP10.phx.gbl...
> > Hi all,
> > How can I convert an integer to its equivalent ascii character
without
> > using Microsoft.VisualBasic dll or any other dll(I want to reference only
> > System.dll).
> >
> > Thanks.
> >
> > -Nikhil
> >
> >
>
>



Nov 20 '05 #11

P: n/a
It uses the Microsoft.VisualBasic.

Telmo Sampaio

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Od**************@TK2MSFTNGP09.phx.gbl...
Nikhil,
ChrW(10) is a constant expression!

Microsoft.VisualBasic will not be loaded!

Which also means that ChrW(10) does it without either
Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).

Only time that ChrW needs to load Microsoft.VisualBasic is when the
parameter is non constant, such as a variable or property.

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Thanks Jay.

The ChrW is in Microsoft.VisualBasic dll. I don't want to load this dll

just
for this one function. Because my application is already very slow.

Is there any way to do this using only System.dll?

Thanks.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Ov**************@TK2MSFTNGP09.phx.gbl...
Nikhil,
Have you looked at ChrW?

Dim ch As Char = ChrW(10)

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:uw**************@tk2msftngp13.phx.gbl...
> Thanks Alex,
> Unfortunately I am using VB.Net not C#.
>
> I tried
>
> CType(10, Char)
>
> in VB.Net. But it returned "1".
>
>
> "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
> news:%2****************@TK2MSFTNGP10.phx.gbl...
> > Nikhil.
> >
> > did you try
> >
> > char c = (char)13;
> >
> > HTH
> > Alex
> >
> > "Nikhil Patel" <ni********@aol.com> wrote in message
> > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > Hi all,
> > > How can I convert an integer to its equivalent ascii character > without
> > > using Microsoft.VisualBasic dll or any other dll(I want to

reference > only
> > > System.dll).
> > >
> > > Thanks.
> > >
> > > -Nikhil
> > >
> > >
> >
> >
>
>



Nov 20 '05 #12

P: n/a
Telmo,
It uses the Microsoft.VisualBasic. Which part of ChrW(10) is a constant do you not understand? :-|
Try it yourself, compile the following:

Public Shared Sub Main()

Dim ch As Char = ChrW(10)

End Sub
Use ILDASM to look at the code created:

method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = ( 01
00 00 00 )
// Code size 6 (0x6)
.maxstack 1
.locals init ([0] char ch)
.language '{3A12D0B8-C26C-11D0-B442-00A0244A1DD2}',
'{994B45C4-E6E9-11D2-903F-00C04FA302A1}',
'{00000000-0000-0000-0000-000000000000}'
// Source File 'C:\Telmo.vb'
//000161: Public Shared Sub Main()
IL_0000: nop
//000162:
//000163: Dim ch As Char = ChrW(10)
IL_0001: ldc.i4.s 10
IL_0003: stloc.0
//000164:
//000165: End Sub
IL_0004: nop
IL_0005: ret
} // end of method Grouping::Main
Where in the above IL do you see Microsoft.VisualBasic?

As I stated before: If the parameter to ChrW is a constant or a literal, the
compiler treats it as a constant Char, Microsoft.VisualBasic is not used!!!

Thanks
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl... It uses the Microsoft.VisualBasic.

Telmo Sampaio

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Od**************@TK2MSFTNGP09.phx.gbl...
Nikhil,
ChrW(10) is a constant expression!

Microsoft.VisualBasic will not be loaded!

Which also means that ChrW(10) does it without either
Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).

Only time that ChrW needs to load Microsoft.VisualBasic is when the
parameter is non constant, such as a variable or property.

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
Thanks Jay.

The ChrW is in Microsoft.VisualBasic dll. I don't want to load this
dll
just
for this one function. Because my application is already very slow.

Is there any way to do this using only System.dll?

Thanks.
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in

message news:Ov**************@TK2MSFTNGP09.phx.gbl...
> Nikhil,
> Have you looked at ChrW?
>
> Dim ch As Char = ChrW(10)
>
> Hope this helps
> Jay
>
> "Nikhil Patel" <ni********@aol.com> wrote in message
> news:uw**************@tk2msftngp13.phx.gbl...
> > Thanks Alex,
> > Unfortunately I am using VB.Net not C#.
> >
> > I tried
> >
> > CType(10, Char)
> >
> > in VB.Net. But it returned "1".
> >
> >
> > "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
> > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > Nikhil.
> > >
> > > did you try
> > >
> > > char c = (char)13;
> > >
> > > HTH
> > > Alex
> > >
> > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > > Hi all,
> > > > How can I convert an integer to its equivalent ascii character > > without
> > > > using Microsoft.VisualBasic dll or any other dll(I want to

reference
> > only
> > > > System.dll).
> > > >
> > > > Thanks.
> > > >
> > > > -Nikhil
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #13

P: n/a
You are right. The VB to MSIL compiler does the work for you (i.e. it sees a
constant and therefore does not make a call to Microsoft.VisualBasic)
exactly as you have mentioned.
I still try not to use it since it is not a 'real' part of the CLS and it is
there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB.

Telmo Sampaio (not good in VB6)

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:#P**************@TK2MSFTNGP12.phx.gbl...
Telmo,
It uses the Microsoft.VisualBasic. Which part of ChrW(10) is a constant do you not understand? :-|
Try it yourself, compile the following:

Public Shared Sub Main()

Dim ch As Char = ChrW(10)

End Sub
Use ILDASM to look at the code created:

method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = (

01 00 00 00 )
// Code size 6 (0x6)
.maxstack 1
.locals init ([0] char ch)
.language '{3A12D0B8-C26C-11D0-B442-00A0244A1DD2}',
'{994B45C4-E6E9-11D2-903F-00C04FA302A1}',
'{00000000-0000-0000-0000-000000000000}'
// Source File 'C:\Telmo.vb'
//000161: Public Shared Sub Main()
IL_0000: nop
//000162:
//000163: Dim ch As Char = ChrW(10)
IL_0001: ldc.i4.s 10
IL_0003: stloc.0
//000164:
//000165: End Sub
IL_0004: nop
IL_0005: ret
} // end of method Grouping::Main
Where in the above IL do you see Microsoft.VisualBasic?

As I stated before: If the parameter to ChrW is a constant or a literal, the compiler treats it as a constant Char, Microsoft.VisualBasic is not used!!!
Thanks
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
It uses the Microsoft.VisualBasic.

Telmo Sampaio

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:Od**************@TK2MSFTNGP09.phx.gbl...
Nikhil,
ChrW(10) is a constant expression!

Microsoft.VisualBasic will not be loaded!

Which also means that ChrW(10) does it without either
Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).

Only time that ChrW needs to load Microsoft.VisualBasic is when the
parameter is non constant, such as a variable or property.

Hope this helps
Jay

"Nikhil Patel" <ni********@aol.com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
> Thanks Jay.
>
> The ChrW is in Microsoft.VisualBasic dll. I don't want to load this

dll just
> for this one function. Because my application is already very slow.
>
> Is there any way to do this using only System.dll?
>
> Thanks.
>
>
> "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in

message
> news:Ov**************@TK2MSFTNGP09.phx.gbl...
> > Nikhil,
> > Have you looked at ChrW?
> >
> > Dim ch As Char = ChrW(10)
> >
> > Hope this helps
> > Jay
> >
> > "Nikhil Patel" <ni********@aol.com> wrote in message
> > news:uw**************@tk2msftngp13.phx.gbl...
> > > Thanks Alex,
> > > Unfortunately I am using VB.Net not C#.
> > >
> > > I tried
> > >
> > > CType(10, Char)
> > >
> > > in VB.Net. But it returned "1".
> > >
> > >
> > > "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message
> > > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > > Nikhil.
> > > >
> > > > did you try
> > > >
> > > > char c = (char)13;
> > > >
> > > > HTH
> > > > Alex
> > > >
> > > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > > > Hi all,
> > > > > How can I convert an integer to its equivalent ascii

character
> > > without
> > > > > using Microsoft.VisualBasic dll or any other dll(I want to
reference
> > > only
> > > > > System.dll).
> > > > >
> > > > > Thanks.
> > > > >
> > > > > -Nikhil
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #14

P: n/a
Telmo,
I still try not to use it since it is not a 'real' part of the CLS and it is there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB. How can it be? CLS is Common Language Specification, which is "the set of
restrictions on the CTS (Common Type System) that ensure interoperability
among language". ChrW is a VB.NET keyword which happens to match the
"(char)" construct in C#. I would not expect ChrW to be part of the CLS any
more then "(char)" to be. The fact it uses a helper function for non
constant parameters is largely immaterial. The helper function simply
ensures that the supplied code point is within the proper range, I
understand that C# simply truncates the integer.

Did you perhaps mean the BCL (Base Class Library)? Does it really matter its
not part of the BCL, considering that Microsoft.VisualBasic is installed
with the framework, effectively making Microsoft.VisualBasic part of the
framework? (Yes it matters if you choose to use Mono, however I understand
that Mono has a Microsoft.VisualBasic assembly).

However! it is NOT there for backward compatibility! It is there as an
integral part of the VB.NET language, just as CType & DirectCast are also an
integral part of the VB.NET language.

You should realize that the contructs in Microsoft.VisualBasic.Compatibility
assembly are there for backward compatibility, which may or may not go away
in newer versions.

The following articles may help you understand the relationship of ChrW and
Convert and other integral parts of the VB.NET language:

http://www.panopticoncentral.net/arc...5/31/1100.aspx

http://www.panopticoncentral.net/arc...6/07/1200.aspx

(not good in VB6) Funny I thought we were talking about VB.NET!

Hope this helps
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl... You are right. The VB to MSIL compiler does the work for you (i.e. it sees a constant and therefore does not make a call to Microsoft.VisualBasic)
exactly as you have mentioned.
I still try not to use it since it is not a 'real' part of the CLS and it is there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB.

Telmo Sampaio (not good in VB6)

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:#P**************@TK2MSFTNGP12.phx.gbl...
Telmo,
It uses the Microsoft.VisualBasic.

Which part of ChrW(10) is a constant do you not understand? :-|
Try it yourself, compile the following:

Public Shared Sub Main()

Dim ch As Char = ChrW(10)

End Sub
Use ILDASM to look at the code created:

method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = (

01
00 00 00 )
// Code size 6 (0x6)
.maxstack 1
.locals init ([0] char ch)
.language '{3A12D0B8-C26C-11D0-B442-00A0244A1DD2}',
'{994B45C4-E6E9-11D2-903F-00C04FA302A1}',
'{00000000-0000-0000-0000-000000000000}'
// Source File 'C:\Telmo.vb'
//000161: Public Shared Sub Main()
IL_0000: nop
//000162:
//000163: Dim ch As Char = ChrW(10)
IL_0001: ldc.i4.s 10
IL_0003: stloc.0
//000164:
//000165: End Sub
IL_0004: nop
IL_0005: ret
} // end of method Grouping::Main
Where in the above IL do you see Microsoft.VisualBasic?

As I stated before: If the parameter to ChrW is a constant or a literal,

the
compiler treats it as a constant Char, Microsoft.VisualBasic is not

used!!!

Thanks
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
It uses the Microsoft.VisualBasic.

Telmo Sampaio

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message news:Od**************@TK2MSFTNGP09.phx.gbl...
> Nikhil,
> ChrW(10) is a constant expression!
>
> Microsoft.VisualBasic will not be loaded!
>
> Which also means that ChrW(10) does it without either
> Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).
>
> Only time that ChrW needs to load Microsoft.VisualBasic is when the
> parameter is non constant, such as a variable or property.
>
> Hope this helps
> Jay
>
> "Nikhil Patel" <ni********@aol.com> wrote in message
> news:%2***************@TK2MSFTNGP12.phx.gbl...
> > Thanks Jay.
> >
> > The ChrW is in Microsoft.VisualBasic dll. I don't want to load this
dll
> just
> > for this one function. Because my application is already very

slow. > >
> > Is there any way to do this using only System.dll?
> >
> > Thanks.
> >
> >
> > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
> > news:Ov**************@TK2MSFTNGP09.phx.gbl...
> > > Nikhil,
> > > Have you looked at ChrW?
> > >
> > > Dim ch As Char = ChrW(10)
> > >
> > > Hope this helps
> > > Jay
> > >
> > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > news:uw**************@tk2msftngp13.phx.gbl...
> > > > Thanks Alex,
> > > > Unfortunately I am using VB.Net not C#.
> > > >
> > > > I tried
> > > >
> > > > CType(10, Char)
> > > >
> > > > in VB.Net. But it returned "1".
> > > >
> > > >
> > > > "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message > > > > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > > > Nikhil.
> > > > >
> > > > > did you try
> > > > >
> > > > > char c = (char)13;
> > > > >
> > > > > HTH
> > > > > Alex
> > > > >
> > > > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > > > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > > > > Hi all,
> > > > > > How can I convert an integer to its equivalent ascii
character
> > > > without
> > > > > > using Microsoft.VisualBasic dll or any other dll(I want to
> reference
> > > > only
> > > > > > System.dll).
> > > > > >
> > > > > > Thanks.
> > > > > >
> > > > > > -Nikhil
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #15

P: n/a
It appears in the Project Imports - Project Properties, Common, Imports.
It can be removed from there. As a note to newbies reading this, looking
through the task list after removing the Imports and References to
Microsoft.VisualBasic, you can get an idea of which statements are now
unavailable.
____________________________________
The Grim Reaper

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
I am a little confused however.
You posted to the VB group, but don't want to include the Microsoft.VisualBasic dll?
You really can't do anything without that.
If you are running the IDE with a VB project open, that is automatically
referenced, and won't even appear in the references.
Are you confusing this dll with the Compatibility dll?

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
CableWizard,
Thanks. It worked.

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
You fail to mention the Text Encoding used, so I will assume the
Integer in
question already represents ASCII.
Here is just a couple of the available methods, there are more
depending upon
encoding.

Dim intChar As Integer = 65 'ASCII "A"
Dim c As Char

c = Chr(intChar)
c = Convert.ToChar(intChar)

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
> Hi all,
> How can I convert an integer to its equivalent ascii character

without
> using Microsoft.VisualBasic dll or any other dll(I want to reference

only
> System.dll).
>
> Thanks.
>
> -Nikhil
>
>



Nov 20 '05 #16

P: n/a
Jay,

As you see in
http://msdn.microsoft.com/library/de...us/vblr7/html/
vafctChr.asp ChrW is part of the Microsoft.VisualBasic Namespace. As a
trainer I show my students the use of System.dll and functions from
Microsoft.VisualBasic, explaining that in some cases the functions will be
even faster than the System.Convert class. However, I do not know if
Microsoft.VisualBasic will be there in the future, it may not. Since we are
talking about that, I liked the article you sent that shows that VS 2005
will go further on VB Functions.

As for the CLS, it is well defined here
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconWhatIsCommonLanguageSpecification.asp where it says that some
features of the Framework are not CLS-compliant and therefore cannot be used
by all languages. I assume that this was the case here, since I cannot
access those functions from other languages.

Telmo
P.S.: I am enjoying the discussion, do not take it personal

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
Telmo,
I still try not to use it since it is not a 'real' part of the CLS and it
is
there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB. How can it be? CLS is Common Language Specification, which is "the set of
restrictions on the CTS (Common Type System) that ensure interoperability
among language". ChrW is a VB.NET keyword which happens to match the
"(char)" construct in C#. I would not expect ChrW to be part of the CLS

any more then "(char)" to be. The fact it uses a helper function for non
constant parameters is largely immaterial. The helper function simply
ensures that the supplied code point is within the proper range, I
understand that C# simply truncates the integer.

Did you perhaps mean the BCL (Base Class Library)? Does it really matter its not part of the BCL, considering that Microsoft.VisualBasic is installed
with the framework, effectively making Microsoft.VisualBasic part of the
framework? (Yes it matters if you choose to use Mono, however I understand
that Mono has a Microsoft.VisualBasic assembly).

However! it is NOT there for backward compatibility! It is there as an
integral part of the VB.NET language, just as CType & DirectCast are also an integral part of the VB.NET language.

You should realize that the contructs in Microsoft.VisualBasic.Compatibility assembly are there for backward compatibility, which may or may not go away in newer versions.

The following articles may help you understand the relationship of ChrW and Convert and other integral parts of the VB.NET language:

http://www.panopticoncentral.net/arc...5/31/1100.aspx

http://www.panopticoncentral.net/arc...6/07/1200.aspx

(not good in VB6) Funny I thought we were talking about VB.NET!

Hope this helps
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You are right. The VB to MSIL compiler does the work for you (i.e. it sees a
constant and therefore does not make a call to Microsoft.VisualBasic)
exactly as you have mentioned.
I still try not to use it since it is not a 'real' part of the CLS and
it is
there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB.

Telmo Sampaio (not good in VB6)

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in

message news:#P**************@TK2MSFTNGP12.phx.gbl...
Telmo,
> It uses the Microsoft.VisualBasic.
Which part of ChrW(10) is a constant do you not understand? :-|
Try it yourself, compile the following:

Public Shared Sub Main()

Dim ch As Char = ChrW(10)

End Sub
Use ILDASM to look at the code created:

method public static void Main() cil managed
{
.entrypoint
.custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = (
01
00 00 00 )
// Code size 6 (0x6)
.maxstack 1
.locals init ([0] char ch)
.language '{3A12D0B8-C26C-11D0-B442-00A0244A1DD2}',
'{994B45C4-E6E9-11D2-903F-00C04FA302A1}',
'{00000000-0000-0000-0000-000000000000}'
// Source File 'C:\Telmo.vb'
//000161: Public Shared Sub Main()
IL_0000: nop
//000162:
//000163: Dim ch As Char = ChrW(10)
IL_0001: ldc.i4.s 10
IL_0003: stloc.0
//000164:
//000165: End Sub
IL_0004: nop
IL_0005: ret
} // end of method Grouping::Main
Where in the above IL do you see Microsoft.VisualBasic?

As I stated before: If the parameter to ChrW is a constant or a
literal, the
compiler treats it as a constant Char, Microsoft.VisualBasic is not

used!!!

Thanks
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:ul**************@TK2MSFTNGP09.phx.gbl...
> It uses the Microsoft.VisualBasic.
>
> Telmo Sampaio
>
> "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in

message
> news:Od**************@TK2MSFTNGP09.phx.gbl...
> > Nikhil,
> > ChrW(10) is a constant expression!
> >
> > Microsoft.VisualBasic will not be loaded!
> >
> > Which also means that ChrW(10) does it without either
> > Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).
> >
> > Only time that ChrW needs to load Microsoft.VisualBasic is when

the > > parameter is non constant, such as a variable or property.
> >
> > Hope this helps
> > Jay
> >
> > "Nikhil Patel" <ni********@aol.com> wrote in message
> > news:%2***************@TK2MSFTNGP12.phx.gbl...
> > > Thanks Jay.
> > >
> > > The ChrW is in Microsoft.VisualBasic dll. I don't want to load

this dll
> > just
> > > for this one function. Because my application is already very slow. > > >
> > > Is there any way to do this using only System.dll?
> > >
> > > Thanks.
> > >
> > >
> > > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in > message
> > > news:Ov**************@TK2MSFTNGP09.phx.gbl...
> > > > Nikhil,
> > > > Have you looked at ChrW?
> > > >
> > > > Dim ch As Char = ChrW(10)
> > > >
> > > > Hope this helps
> > > > Jay
> > > >
> > > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > > news:uw**************@tk2msftngp13.phx.gbl...
> > > > > Thanks Alex,
> > > > > Unfortunately I am using VB.Net not C#.
> > > > >
> > > > > I tried
> > > > >
> > > > > CType(10, Char)
> > > > >
> > > > > in VB.Net. But it returned "1".
> > > > >
> > > > >
> > > > > "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in message > > > > > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > > > > Nikhil.
> > > > > >
> > > > > > did you try
> > > > > >
> > > > > > char c = (char)13;
> > > > > >
> > > > > > HTH
> > > > > > Alex
> > > > > >
> > > > > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > > > > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > > > > > Hi all,
> > > > > > > How can I convert an integer to its equivalent ascii
> character
> > > > > without
> > > > > > > using Microsoft.VisualBasic dll or any other dll(I want to > > reference
> > > > > only
> > > > > > > System.dll).
> > > > > > >
> > > > > > > Thanks.
> > > > > > >
> > > > > > > -Nikhil
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #17

P: n/a
ah, hmm... good to know. however I have never had any reason to consider
removing it. since we are coding in VB, i'm curious as to why someone would want
to remove the reference. a comment was made about performance, does referencing
this dll somehow slow things down?

Gerald
"The Grim Reaper" <gr*********@btopenworld.com> wrote in message
news:cd**********@titan.btinternet.com...
It appears in the Project Imports - Project Properties, Common, Imports.
It can be removed from there. As a note to newbies reading this, looking
through the task list after removing the Imports and References to
Microsoft.VisualBasic, you can get an idea of which statements are now
unavailable.
____________________________________
The Grim Reaper

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
I am a little confused however.
You posted to the VB group, but don't want to include the

Microsoft.VisualBasic
dll?
You really can't do anything without that.
If you are running the IDE with a VB project open, that is automatically
referenced, and won't even appear in the references.
Are you confusing this dll with the Compatibility dll?

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
CableWizard,
Thanks. It worked.

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:O4**************@TK2MSFTNGP11.phx.gbl...
> You fail to mention the Text Encoding used, so I will assume the Integer in
> question already represents ASCII.
> Here is just a couple of the available methods, there are more depending upon
> encoding.
>
> Dim intChar As Integer = 65 'ASCII "A"
> Dim c As Char
>
> c = Chr(intChar)
> c = Convert.ToChar(intChar)
>
> Gerald
>
> "Nikhil Patel" <ni********@aol.com> wrote in message
> news:en**************@TK2MSFTNGP10.phx.gbl...
> > Hi all,
> > How can I convert an integer to its equivalent ascii character
without
> > using Microsoft.VisualBasic dll or any other dll(I want to reference
only
> > System.dll).
> >
> > Thanks.
> >
> > -Nikhil
> >
> >
>
>



Nov 20 '05 #18

P: n/a
Telmo,
You do realize the fact that the ChrW keyword calls into
Microsoft.VisualBasic is an implementation detail that you really should not
worry about!

Also I find it better to write (and teach) "correct" programs then to worry
about this function performs better then that function. By "correct" I mean
OO and use the correct tool for the correct job (for example: when to use
ChrW and when to use Convert.ToChar). Remember that most programs follow the
80/20 rule (link below) that is 80% of the execution time of your program is
spent in 20% of your code. I will optimize a routine once that routine has
proven to be a performance problem via profiling (link below).

Like I stated it is ChrW is an integral part of the VB.NET language, if
Microsoft.VisualBasic should happen to no longer be available, I suspect
that the compiler will implement ChrW in a different manner, as ChrW is a
keyword. At the same time I can also see ChrW being implemented inline in
more cases while Microsoft.VisualBasic continues to be available...
I assume that this was the case here, since I cannot
access those functions from other languages. Oh Really!! Most of Microsoft.Visualbasic you can access from any .NET
language you want, as they are "pure .NET" functions. I say "Most" as some
of the function as undocumented, this does not mean you cannot access them,
it just means they are undocumented & subject to change. Documented
functions would be marked as Obsolete, if changed...

For example, open a C# project, use 'Project - Reference - Add Reference' to
add a reference to the "Microsoft Visual Basic .NET Runtime", then call
"Microsoft.VisualBasic.Strings.Split"

using Microsoft.VisualBasic;

string [] fields = Strings.Split(Line2, "\r\n", -1,
CompareMethod.Binary);

For info on the 80/20 rule & optimizing only the 20% see Martin Fowler's
article "Yet Another Optimization Article" at
http://martinfowler.com/ieeeSoftware...timization.pdf

For a list of Martin's articles see:

http://martinfowler.com/articles.html

Info on the CLR Profiler:
http://msdn.microsoft.com/library/de...nethowto13.asp

http://msdn.microsoft.com/library/de...anagedapps.asp
Hope this helps
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Jay,

As you see in
http://msdn.microsoft.com/library/de...us/vblr7/html/ vafctChr.asp ChrW is part of the Microsoft.VisualBasic Namespace. As a
trainer I show my students the use of System.dll and functions from
Microsoft.VisualBasic, explaining that in some cases the functions will be
even faster than the System.Convert class. However, I do not know if
Microsoft.VisualBasic will be there in the future, it may not. Since we are talking about that, I liked the article you sent that shows that VS 2005
will go further on VB Functions.

As for the CLS, it is well defined here
http://msdn.microsoft.com/library/de...us/cpguide/htm l/cpconWhatIsCommonLanguageSpecification.asp where it says that some
features of the Framework are not CLS-compliant and therefore cannot be used by all languages. I assume that this was the case here, since I cannot
access those functions from other languages.

Telmo
P.S.: I am enjoying the discussion, do not take it personal

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
Telmo,
I still try not to use it since it is not a 'real' part of the CLS and it
is
there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB. How can it be? CLS is Common Language Specification, which is "the set of restrictions on the CTS (Common Type System) that ensure interoperability among language". ChrW is a VB.NET keyword which happens to match the
"(char)" construct in C#. I would not expect ChrW to be part of the CLS

any
more then "(char)" to be. The fact it uses a helper function for non
constant parameters is largely immaterial. The helper function simply
ensures that the supplied code point is within the proper range, I
understand that C# simply truncates the integer.

Did you perhaps mean the BCL (Base Class Library)? Does it really matter

its
not part of the BCL, considering that Microsoft.VisualBasic is installed
with the framework, effectively making Microsoft.VisualBasic part of the
framework? (Yes it matters if you choose to use Mono, however I understand that Mono has a Microsoft.VisualBasic assembly).

However! it is NOT there for backward compatibility! It is there as an
integral part of the VB.NET language, just as CType & DirectCast are

also an
integral part of the VB.NET language.

You should realize that the contructs in Microsoft.VisualBasic.Compatibility
assembly are there for backward compatibility, which may or may not go

away
in newer versions.

The following articles may help you understand the relationship of ChrW

and
Convert and other integral parts of the VB.NET language:

http://www.panopticoncentral.net/arc...5/31/1100.aspx

http://www.panopticoncentral.net/arc...6/07/1200.aspx

(not good in VB6)

Funny I thought we were talking about VB.NET!

Hope this helps
Jay

"Telmo Sampaio" <ts******@gmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
You are right. The VB to MSIL compiler does the work for you (i.e. it

sees
a
constant and therefore does not make a call to Microsoft.VisualBasic)
exactly as you have mentioned.
I still try not to use it since it is not a 'real' part of the CLS and

it
is
there for backward compatibility. I accept change and hope to see this
backard compatibility go away in newer versions of VB.

Telmo Sampaio (not good in VB6)

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in

message news:#P**************@TK2MSFTNGP12.phx.gbl...
> Telmo,
> > It uses the Microsoft.VisualBasic.
> Which part of ChrW(10) is a constant do you not understand? :-|
>
>
> Try it yourself, compile the following:
>
> Public Shared Sub Main()
>
> Dim ch As Char = ChrW(10)
>
> End Sub
>
>
> Use ILDASM to look at the code created:
>
> method public static void Main() cil managed
> {
> .entrypoint
> .custom instance void [mscorlib]System.STAThreadAttribute::.ctor() = (
01
> 00 00 00 )
> // Code size 6 (0x6)
> .maxstack 1
> .locals init ([0] char ch)
> .language '{3A12D0B8-C26C-11D0-B442-00A0244A1DD2}',
> '{994B45C4-E6E9-11D2-903F-00C04FA302A1}',
> '{00000000-0000-0000-0000-000000000000}'
> // Source File 'C:\Telmo.vb'
> //000161: Public Shared Sub Main()
> IL_0000: nop
> //000162:
> //000163: Dim ch As Char = ChrW(10)
> IL_0001: ldc.i4.s 10
> IL_0003: stloc.0
> //000164:
> //000165: End Sub
> IL_0004: nop
> IL_0005: ret
> } // end of method Grouping::Main
>
>
> Where in the above IL do you see Microsoft.VisualBasic?
>
> As I stated before: If the parameter to ChrW is a constant or a literal, the
> compiler treats it as a constant Char, Microsoft.VisualBasic is not
used!!!
>
> Thanks
> Jay
>
> "Telmo Sampaio" <ts******@gmail.com> wrote in message
> news:ul**************@TK2MSFTNGP09.phx.gbl...
> > It uses the Microsoft.VisualBasic.
> >
> > Telmo Sampaio
> >
> > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in
message
> > news:Od**************@TK2MSFTNGP09.phx.gbl...
> > > Nikhil,
> > > ChrW(10) is a constant expression!
> > >
> > > Microsoft.VisualBasic will not be loaded!
> > >
> > > Which also means that ChrW(10) does it without either
> > > Microsoft.VisualBasic.dll or System.dll (mscorlib.dll really).
> > >
> > > Only time that ChrW needs to load Microsoft.VisualBasic is when the > > > parameter is non constant, such as a variable or property.
> > >
> > > Hope this helps
> > > Jay
> > >
> > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > news:%2***************@TK2MSFTNGP12.phx.gbl...
> > > > Thanks Jay.
> > > >
> > > > The ChrW is in Microsoft.VisualBasic dll. I don't want to load this
> dll
> > > just
> > > > for this one function. Because my application is already very

slow.
> > > >
> > > > Is there any way to do this using only System.dll?
> > > >
> > > > Thanks.
> > > >
> > > >
> > > > "Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in > > message
> > > > news:Ov**************@TK2MSFTNGP09.phx.gbl...
> > > > > Nikhil,
> > > > > Have you looked at ChrW?
> > > > >
> > > > > Dim ch As Char = ChrW(10)
> > > > >
> > > > > Hope this helps
> > > > > Jay
> > > > >
> > > > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > > > news:uw**************@tk2msftngp13.phx.gbl...
> > > > > > Thanks Alex,
> > > > > > Unfortunately I am using VB.Net not C#.
> > > > > >
> > > > > > I tried
> > > > > >
> > > > > > CType(10, Char)
> > > > > >
> > > > > > in VB.Net. But it returned "1".
> > > > > >
> > > > > >
> > > > > > "AlexS" <sa***********@SPAMsympaticoPLEASE.ca> wrote in

message
> > > > > > news:%2****************@TK2MSFTNGP10.phx.gbl...
> > > > > > > Nikhil.
> > > > > > >
> > > > > > > did you try
> > > > > > >
> > > > > > > char c = (char)13;
> > > > > > >
> > > > > > > HTH
> > > > > > > Alex
> > > > > > >
> > > > > > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > > > > > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > > > > > > Hi all,
> > > > > > > > How can I convert an integer to its equivalent
ascii > > character
> > > > > > without
> > > > > > > > using Microsoft.VisualBasic dll or any other dll(I

want to > > > reference
> > > > > > only
> > > > > > > > System.dll).
> > > > > > > >
> > > > > > > > Thanks.
> > > > > > > >
> > > > > > > > -Nikhil
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > >
> > > > > >
> > > > >
> > > > >
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #19

P: n/a
Gerald,
Yes referencing a DLL "can" slow down your app as the DLL needs to be
loaded, and the types within the DLL need to be loaded.

However! even it you remove the reference, VB.NET will still create your
assembly with a reference and call into it.

For example look at ILDASM on the following:

Dim s1, s2 As String

If s1 = s2 Then

End If

Rather then worry about removing Microsoft.VisualBasic I would be more
concerned in "right sizing" the assemblies I create...
Personally the VB in VB.NET stands for Visual Basic! ChrW is part of the
VB.NET language, so use it where its appropriate.
Microsoft.VisualBasic.Strings.Split is part of the VB.NET runtime, so use it
where it makes sense.

My only real cautions on Microsoft.VisualBasic are:
1. Avoid Collection as its too generalized, use System.Collections &
System.Collections.Specialized instead. (this is more an OO thing then
anything).
2. Don't mix System.String with Microsoft.VisualBasic.Strings, as VB.Strings
are all 1 based functions, while System.String are 0 based functions. I will
use VB.Strings.Split with System.String where I do need to split based on a
word...

Also as I told Telmo I would not worry about performance when you are
writing your app, I would worry about performance once a routine has proven
to be a performance problem... (the 80/20 rule).

Hope this helps
Jay

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:eh****************@tk2msftngp13.phx.gbl...
ah, hmm... good to know. however I have never had any reason to consider
removing it. since we are coding in VB, i'm curious as to why someone would want to remove the reference. a comment was made about performance, does referencing this dll somehow slow things down?

Gerald

<<snip>>
Nov 20 '05 #20

P: n/a
Sounds like most of this is just plain sound coding practices.
Personally, I've found most performance issues are due to implementation, and
rethinking the logic and implementation is more appropriate than trying to
squeeze in more ill-conceived operations per second.
As far as Collections go, I agree. In most cases, if a Collection is appropriate
I implement my own strongly typed collection and querying logic.
So in the end, I still don't see the point of removing the reference to the DLL.
In my case, I knew that would be the case as I use the heck out of the VB stuff,
but I was curious.

Although with the recent chatter about Strings, I may research this some more
and some changes in my usage may be beneficial.

Thanks,
Gerald

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O6*************@TK2MSFTNGP10.phx.gbl...
Gerald,
Yes referencing a DLL "can" slow down your app as the DLL needs to be
loaded, and the types within the DLL need to be loaded.

However! even it you remove the reference, VB.NET will still create your
assembly with a reference and call into it.

For example look at ILDASM on the following:

Dim s1, s2 As String

If s1 = s2 Then

End If

Rather then worry about removing Microsoft.VisualBasic I would be more
concerned in "right sizing" the assemblies I create...
Personally the VB in VB.NET stands for Visual Basic! ChrW is part of the
VB.NET language, so use it where its appropriate.
Microsoft.VisualBasic.Strings.Split is part of the VB.NET runtime, so use it
where it makes sense.

My only real cautions on Microsoft.VisualBasic are:
1. Avoid Collection as its too generalized, use System.Collections &
System.Collections.Specialized instead. (this is more an OO thing then
anything).
2. Don't mix System.String with Microsoft.VisualBasic.Strings, as VB.Strings
are all 1 based functions, while System.String are 0 based functions. I will
use VB.Strings.Split with System.String where I do need to split based on a
word...

Also as I told Telmo I would not worry about performance when you are
writing your app, I would worry about performance once a routine has proven
to be a performance problem... (the 80/20 rule).

Hope this helps
Jay

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:eh****************@tk2msftngp13.phx.gbl...
ah, hmm... good to know. however I have never had any reason to consider
removing it. since we are coding in VB, i'm curious as to why someone

would want
to remove the reference. a comment was made about performance, does

referencing
this dll somehow slow things down?

Gerald

<<snip>>

Nov 20 '05 #21

P: n/a
On Tue, 13 Jul 2004 14:12:25 -0400, "Nikhil Patel"
<ni********@aol.com> wrote:
Hi all,
How can I convert an integer to its equivalent ascii character without
using Microsoft.VisualBasic dll or any other dll(I want to reference only
System.dll).

Thanks.

-Nikhil


Dim s as string
Dim i as integer = 13

s = chr(i)

s now equals CR

HTH,
Tibby
Nov 20 '05 #22

P: n/a
I'm not sure of any performance issues - most of my stuff is utilities,
nothing overly large or processor hungry.
Obviously one less DLL in the bin folder when you're distributing apps is
useful sometimes - might even fit on a floppy if you're lucky!!
I suppose I was curious the first time to see how many imports and
references I could remove.. lol.. I can actually get most programs to not
use any VisualBasic libraries - I guess making a "pure" .NET app makes me
feel just that little bit better :)
________________________________
The Grim Reaper

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:eh****************@tk2msftngp13.phx.gbl...
ah, hmm... good to know. however I have never had any reason to consider
removing it. since we are coding in VB, i'm curious as to why someone would want to remove the reference. a comment was made about performance, does referencing this dll somehow slow things down?

Gerald
"The Grim Reaper" <gr*********@btopenworld.com> wrote in message
news:cd**********@titan.btinternet.com...
It appears in the Project Imports - Project Properties, Common, Imports.
It can be removed from there. As a note to newbies reading this, looking through the task list after removing the Imports and References to
Microsoft.VisualBasic, you can get an idea of which statements are now
unavailable.
____________________________________
The Grim Reaper

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
I am a little confused however.
You posted to the VB group, but don't want to include the

Microsoft.VisualBasic
dll?
You really can't do anything without that.
If you are running the IDE with a VB project open, that is automatically referenced, and won't even appear in the references.
Are you confusing this dll with the Compatibility dll?

Gerald

"Nikhil Patel" <ni********@aol.com> wrote in message
news:eH**************@TK2MSFTNGP10.phx.gbl...
> CableWizard,
> Thanks. It worked.
>
> "Cablewizard" <Ca*********@Yahoo.com> wrote in message
> news:O4**************@TK2MSFTNGP11.phx.gbl...
> > You fail to mention the Text Encoding used, so I will assume the

Integer
> in
> > question already represents ASCII.
> > Here is just a couple of the available methods, there are more

depending
> upon
> > encoding.
> >
> > Dim intChar As Integer = 65 'ASCII "A"
> > Dim c As Char
> >
> > c = Chr(intChar)
> > c = Convert.ToChar(intChar)
> >
> > Gerald
> >
> > "Nikhil Patel" <ni********@aol.com> wrote in message
> > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > Hi all,
> > > How can I convert an integer to its equivalent ascii character > without
> > > using Microsoft.VisualBasic dll or any other dll(I want to reference > only
> > > System.dll).
> > >
> > > Thanks.
> > >
> > > -Nikhil
> > >
> > >
> >
> >
>
>



Nov 20 '05 #23

P: n/a
heh, but as Jay pointed out, the VisualBasic libaries are part of the .Net
library, so you wouldn't be distributing that DLL anyway.
but writing utilities that use nothing more than the System.dll might be a fun
exercise.

Gerald

"The Grim Reaper" <gr*********@btopenworld.com> wrote in message
news:cd**********@titan.btinternet.com...
I'm not sure of any performance issues - most of my stuff is utilities,
nothing overly large or processor hungry.
Obviously one less DLL in the bin folder when you're distributing apps is
useful sometimes - might even fit on a floppy if you're lucky!!
I suppose I was curious the first time to see how many imports and
references I could remove.. lol.. I can actually get most programs to not
use any VisualBasic libraries - I guess making a "pure" .NET app makes me
feel just that little bit better :)
________________________________
The Grim Reaper

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:eh****************@tk2msftngp13.phx.gbl...
ah, hmm... good to know. however I have never had any reason to consider
removing it. since we are coding in VB, i'm curious as to why someone

would want
to remove the reference. a comment was made about performance, does

referencing
this dll somehow slow things down?

Gerald
"The Grim Reaper" <gr*********@btopenworld.com> wrote in message
news:cd**********@titan.btinternet.com...
It appears in the Project Imports - Project Properties, Common, Imports.
It can be removed from there. As a note to newbies reading this, looking through the task list after removing the Imports and References to
Microsoft.VisualBasic, you can get an idea of which statements are now
unavailable.
____________________________________
The Grim Reaper

"Cablewizard" <Ca*********@Yahoo.com> wrote in message
news:u3**************@TK2MSFTNGP09.phx.gbl...
> I am a little confused however.
> You posted to the VB group, but don't want to include the
Microsoft.VisualBasic
> dll?
> You really can't do anything without that.
> If you are running the IDE with a VB project open, that is automatically > referenced, and won't even appear in the references.
> Are you confusing this dll with the Compatibility dll?
>
> Gerald
>
> "Nikhil Patel" <ni********@aol.com> wrote in message
> news:eH**************@TK2MSFTNGP10.phx.gbl...
> > CableWizard,
> > Thanks. It worked.
> >
> > "Cablewizard" <Ca*********@Yahoo.com> wrote in message
> > news:O4**************@TK2MSFTNGP11.phx.gbl...
> > > You fail to mention the Text Encoding used, so I will assume the
Integer
> > in
> > > question already represents ASCII.
> > > Here is just a couple of the available methods, there are more
depending
> > upon
> > > encoding.
> > >
> > > Dim intChar As Integer = 65 'ASCII "A"
> > > Dim c As Char
> > >
> > > c = Chr(intChar)
> > > c = Convert.ToChar(intChar)
> > >
> > > Gerald
> > >
> > > "Nikhil Patel" <ni********@aol.com> wrote in message
> > > news:en**************@TK2MSFTNGP10.phx.gbl...
> > > > Hi all,
> > > > How can I convert an integer to its equivalent ascii character > > without
> > > > using Microsoft.VisualBasic dll or any other dll(I want to reference > > only
> > > > System.dll).
> > > >
> > > > Thanks.
> > > >
> > > > -Nikhil
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Nov 20 '05 #24

This discussion thread is closed

Replies have been disabled for this discussion.