PC Review


Reply
Thread Tools Rate Thread

converting int to char

 
 
Nikhil Patel
Guest
Posts: n/a
 
      13th Jul 2004
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


 
Reply With Quote
 
 
 
 
AlexS
Guest
Posts: n/a
 
      13th Jul 2004
Nikhil.

did you try

char c = (char)13;

HTH
Alex

"Nikhil Patel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Nikhil Patel
Guest
Posts: n/a
 
      13th Jul 2004
Thanks Alex,
Unfortunately I am using VB.Net not C#.

I tried

CType(10, Char)

in VB.Net. But it returned "1".


"AlexS" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Nikhil.
>
> did you try
>
> char c = (char)13;
>
> HTH
> Alex
>
> "Nikhil Patel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Jay B. Harlow [MVP - Outlook]
Guest
Posts: n/a
 
      13th Jul 2004
Nikhil,
Have you looked at ChrW?

Dim ch As Char = ChrW(10)

Hope this helps
Jay

"Nikhil Patel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Thanks Alex,
> Unfortunately I am using VB.Net not C#.
>
> I tried
>
> CType(10, Char)
>
> in VB.Net. But it returned "1".
>
>
> "AlexS" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Nikhil.
> >
> > did you try
> >
> > char c = (char)13;
> >
> > HTH
> > Alex
> >
> > "Nikhil Patel" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Cablewizard
Guest
Posts: n/a
 
      13th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Nikhil Patel
Guest
Posts: n/a
 
      13th Jul 2004
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Nikhil,
> Have you looked at ChrW?
>
> Dim ch As Char = ChrW(10)
>
> Hope this helps
> Jay
>
> "Nikhil Patel" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Thanks Alex,
> > Unfortunately I am using VB.Net not C#.
> >
> > I tried
> >
> > CType(10, Char)
> >
> > in VB.Net. But it returned "1".
> >
> >
> > "AlexS" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > Nikhil.
> > >
> > > did you try
> > >
> > > char c = (char)13;
> > >
> > > HTH
> > > Alex
> > >
> > > "Nikhil Patel" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed)...
> > > > 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
> > > >
> > > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Cablewizard
Guest
Posts: n/a
 
      13th Jul 2004
Sorry, failed to notice the part about just System.dll
These are of course in the VisualBasic portion.

"Cablewizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Nikhil Patel
Guest
Posts: n/a
 
      13th Jul 2004
CableWizard,
Thanks. It worked.

"Cablewizard" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
Telmo Sampaio
Guest
Posts: n/a
 
      13th Jul 2004
use the Convert static class.

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

Telmo Sampaio

"Nikhil Patel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Cablewizard
Guest
Posts: n/a
 
      13th Jul 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> CableWizard,
> Thanks. It worked.
>
> "Cablewizard" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to permanently delete char char char char style in MS Word? =?Utf-8?B?Q3Jpcw==?= Microsoft Word Document Management 6 12th Jun 2011 09:47 PM
Ever seen "Char Char Char Char Char Char1 Char Char Ch" style? =?Utf-8?B?TWFyaWx5bg==?= Microsoft Word Document Management 2 4th Oct 2006 04:47 PM
suggestions on converting a char to a Key? Flip Microsoft Dot NET Framework 0 4th Apr 2005 03:32 PM
Converting Char[] to String? Marcio Kleemann Microsoft C# .NET 18 22nd Aug 2004 02:28 AM
(unsafe) Converting char*[] -> char** for PInvoke call Adam Clauss Microsoft C# .NET 1 28th Apr 2004 10:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:50 AM.