Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Convert Char To ASCII Code


Helo! Any idea ya? Or i should convert one by one?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Convert Char To ASCII
I was wondering if there was a way to check that the first character in a string is a letter vs. a number.
Example: "123M" vs. "M123"
I was thinking of taking the first charcter, changing it to its ASCII value and comparing it with ASCII value of letters vs. numbers to figure it out that way..
Is there some feature in VB 6.0 that i can use to see whether the character is a letter or number? (Zero is included in the numbers.)

Thanks!!

Getting A Char From It's ASCII Code
Hi
I'm writing a function to create random strings and I do something like

string = string + Chr(random_ascii_value)

It works to some extent but not exactely as I expect it to.
It only generates upper chars and simbols like : ; > =
The random_ascii_vaule is in fact at least 97 (ASCII code for 'a') and at most 97 + 24 ('z' I think).
Does this has to do with 2 bytes strings (unicode?) or what?
So how can I generate the plain char for a ASCII value if CHR doesn't do that?
Thanks

String/Char -> Ascii Code
Duz ne1 have any idea how 2 convert a string to ascii code, i had an example which i converted from Liberty basic code to visual basic code, but i've lost it since multiple formatting of harddrives hope someone can help! thanks
gaz

Code Page Problem For The Char Where ASCII > 127
Just a very simple code:
Code:
Dim sStr as String
sStr = Chr(150)
debug.Print ASC(sStr)


When running the above code in egnlish windows, it can return 150, but When running it in Double-Bytes Windows Environment (such as Traditional Chinese), it will return 0.
I have tried ASCB(sStr) but the result is same.

Anyone know how to solve this case?

How To Convert Ascii To Hex Code?
How to convert Hex code to ASCII code and convert
ASCII code to HEX code by VB code?
how to analyse the hex code bit by bit?

Convert Hex To ASCII, Code Is Attached
Arnout, I don't see CLng() returns a Decimal value from Hex. I tried as follows but a mismatch error happens. It only takes values 0 to 9

Option Explicit

Dim SMSOctetOutput

Dim StrHextoDecimal, StrDecimalToAscii

Dim strText


Private Sub Command1_Click()


SMSOutput = Text1.Text


StrHextoDecimal = CLng(SMSOctetOutput)

StrDecimalToAscii = Str(StrHextoDecimal)

Text2.Text = StrDecimalToAscii


End Sub


My intention is to convert a Hex value to ASCII

Convert ASCII Code To Character
I am able to get the ASCII code for a character by using the Asc function, but how do I go about getting the character for that ASCII code? If there a command that is pretty much the opposite of Asc?

-Matt.
<('.')>
"Unthinking respect for authority is the greatest enemy of the Truth."

Convert Character To Ascii Code?
hi,

Is there anybody help me on this.
How can i convert Character A or B or C and other, to ASCII code

Thank you very much
Regards
Ooi

How To Convert Binary Code To Ascii Code
Does anyone know how to convert binary file to text file

Comport Read Code(how I Wil Convert Ascii To Decimal)
Respected Sir

I am facing problem to read data from comport I have used MSCOMM but i am getting data in ASCII code But i want it in decimal format How i will get it ?

Your help (sample code) and guidance is greately appreciated!

Regards

Bama

Ascii &lt;-&gt; Char
Hi...Can anyone tell me how to convert a character to an ascii value and vice-versa?

Ascii Char
Hello,

I made a program for read ascii characters from modem with win 98 2 ed. and VB6, It were working fine, but now I change to winxp and I can't see the ascii characters and I need these characters for controll the program.

I mean I started to read the string with char(13) and separate between fields with "," and end of the string with vbcrfl, but If I can't see the ascii character, I can´t read the string:

the string is CR,field1, field2,...,fieldn,CRLF.

Someone told me that I need to change the mscomm.ocx for mscomm32.ocx, I put it but nothig change I still can't see the ascii charcaters.

As matter of fact I read ||OK||AT121345678||..... with win98, and
I read with win xp ⌂⌂OK⌂⌂AT12345678⌂⌂

Any advices

Thank you in advance
Victor

Convert Ascii Constant To Ascii Value With Program
How would I go about doin the following? If a string contains "vbKeyF1", how would i get vbKeyF1's ASCII value equivalent (ie: 112) to be written in another string?



Edited by - Marce22 on 10/10/2003 7:04:38 PM

Unicode Char To Extended ASCII
i not sure whether i using the right header.
however i came across a website that is able to display some words that i believe to be arabic characters using "ãäÊíÈáíãÈáÊájhgjsfáÈÓÔí" using only a normal label..

i believe the same can be done with chinese characters.
but with the chinese characters, how do i do the reverse to achieve characters such as "ãäÊíÈ"

Thanks,

Single Ascii Char To File
I'm trying to add a single byte to a file of chr(175). It's a control character to another program.

I use the following code

Dim chrStart As System.Char
Dim chrEnd As System.Char
chrStart = Chr(175) ' ascii af
chrEnd = Chr(174) 'ascii ae
Dim sr As StreamWriter = File.AppendText(ConfigurationSettings.AppSettings("RootDirectory") & "xf" & Session("Agency") & ".sst")
sr.WriteLine(chrStart & "5H-SPECIAL SERVICE TRANSACTIONS" & "{ENTER}" & chrEnd)
sr.close

When I look at it in a hex editor I get c2 af and c2 ae.

I'm assuming the c2 is a unicode thing but I can't figure out how to get rid of it. I just want the af and ae written to the file.

Any ideas????

Ascii To Char &amp; Vice Versa
In VB 6.0 I have to make a simple program that convertas ASCII (ANSI) to the character & vice versa. I have to have a picbox, 2 cmd buttons, and of course the text box, I have all of them and they are all correctly labeled, i need help with the code. I cannot seem to get the code right, here is what I have put down so far...

Private Sub cmdValue_Click()
Dim Ascii As Integer
picOutput.Print "The ANSI Value "; txtInput.Text; " represents the charater"; KeyAscii
End Sub

How To Display The Char Whose ASCII Value Ranges From 1 To 31?
Dear all,
I am working on a VB program which allows the user to type in any chars whose ASCII values range from 1 to 255. But, it seems the TextBox or Rich Text Box that VB carries can NOT display some of the chars with ASCII values ranging from 1 to 31. For example, ATL+1 can not display the SOH char in the text box. But, I do have a program in hand whose text box can display SOH as a smilling face. I don't know what operation is taken behind the scene. Is there a way for my VB program to display those chars with ASCII value 1 to 31? Please advise and thanks in advance...

Tracy

How To Return The Ascii Value (int) For Each Char In A String (harder Than It Sounds)
ive got unicode in a textbox (forms 2.0 control)

ive got 2 characters in there
Text2 = ChrW$(27489) & ChrW(36814) 'says welcome in chinese

but using the code
For x = 1 To Len(Text2.Text)
Debug.Print AscW(Mid(Text2.Text, x, 1))
Next

it returns 27489 and -28722 (not 27489 and 36814)



edit:
on a side note, anyone know how to input unicode characters from a file into a textbox? ive tried but it seems the max char i can get is 255

Building Char Strings, Chars ASCII &gt; 127 &amp; Chinese Windows
An app (VB) that we have had running for a few years now has been working fine on American and European versions of Windows. Now someone has tried to run it on Chinese Windows, and it's not working. I have traced it down to one specific thing, as follows:

The code builds up Modbus communications messages one byte at a time using VB's Chr$() function, like this:

strMessage = Chr$(1) & Chr$(3) & Chr$(0) & Chr$(48) ... etc.

Now, as we all know an unsigned byte can be from 0 - 255. Also, in a single byte character system, ASCII characters also go from 0 to 255. Thus, it is quite natural to want to add such bytes beyond 127, which would be negative values _if_treated_as_signed_bytes_:

strMessage = strMessage & Chr$(245) & Chr$(136)

Now, on most systems this works just dandy. But I have discovered that whenever we try to add a byte (character) > 127 under Chinese Windows, it instead ends up with 0 there - it doesn't seem to get it right.

All suspicions point to MBCS (multi-byte character set) issues, but I was under the impression that VB handles this automatically.

Can anyone suggest how I might successfully add bytes > 127 to a VB string, using VB methods? When I get totally desperate I can call to a C++ DLL to do it, but there's a fair bit of work rewriting the VB code for that so it's a very last resort!

--
Jason Teagle
jason@teagster.co.uk
-----------------------------------------------------------
A list of programming resources I use:
ML: www.windev.org, www.codecipher.com, www.beginthread.com
MB: www.codeguru.com, www.codeproject.com
NG: comp.lang.java.*
OI: www.php.net
-----------------------------------------------------------

Building Char Strings, Chars ASCII &gt; 127 &amp; Chinese Windows
An app (VB) that we have had running for a few years now has been working fine on American and European versions of Windows. Now someone has tried to run it on Chinese Windows, and it's not working. I have traced it down to one specific thing, as follows:

The code builds up Modbus communications messages one byte at a time using VB's Chr$() function, like this:

strMessage = Chr$(1) & Chr$(3) & Chr$(0) & Chr$(48) ... etc.

Now, as we all know an unsigned byte can be from 0 - 255. Also, in a single byte character system, ASCII characters also go from 0 to 255. Thus, it is quite natural to want to add such bytes beyond 127, which would be negative values _if_treated_as_signed_bytes_:

strMessage = strMessage & Chr$(245) & Chr$(136)

Now, on most systems this works just dandy. But I have discovered that whenever we try to add a byte (character) > 127 under Chinese Windows, it instead ends up with 0 there - it doesn't seem to get it right.

All suspicions point to MBCS (multi-byte character set) issues, but I was under the impression that VB handles this automatically.

Can anyone suggest how I might successfully add bytes > 127 to a VB string, using VB methods? When I get totally desperate I can call to a C++ DLL to do it, but there's a fair bit of work rewriting the VB code for that so it's a very last resort!

--
Jason Teagle
jason@teagster.co.uk
-----------------------------------------------------------
A list of programming resources I use:
ML: www.windev.org, www.codecipher.com, www.beginthread.com
MB: www.codeguru.com, www.codeproject.com
NG: comp.lang.java.*
OI: www.php.net
-----------------------------------------------------------

Convert Char To Int
Problem:
Can't convert char to an int, it does work on databases that was created on SQL 2000 but not when they are created in SQL 7.
I am running SQL 2000, imported a db from SQL 7

Field in db: personnr char (10)
I would like to do this(extract from a sql query):

...
left(person_nr,2) between 19 and 20

Error message:
Syntax error converting the varchar value 'DE' to a column of data type int.

Tried cast(ltrim(left(person_nr,2)), as int)
and also convert(int, ltrim(left(person_nr,2)))

But no luck

/Jerry

How To Convert Integer To Char?
I have a c++ function that convert an int type to char type, and I need to write a similar one in VB.
Can anyone please help me?

The c++ function is:

template <class T> void ConvertToChar(char* buff,T item)
{
int itemSize = sizeof(item);

for(int i=0;i<itemSize;i++)
{
buff[((itemSize-1) - i)] = char(item);// extract each byte, starting with hi byte
item >>= 8;
}
}


The call to the function is:

short mMsgLength;
char buff[2];

mMsgLength = fGetMsgLength(); // returns unsigned short
ConvertToChar(buff,mMsgLength);


Thanks,
Kruvi

Convert A Char To Binary
Am trying to convert a char into binary
sending the char to function bin in ascii form
is the conversion function correct

VB Code:
Public Function bin(ByVal a As Integer) Dim j, k As IntegerDim str As String str = ""i = 0j = ak = 0'MsgBox " value recieved " & jWhile j <> 0k = j Mod 2str = str & kj = j / 2'MsgBox jWend   bin = strEnd Function

How To Convert String To Char*
Hi,
My Dll takes char * as argument,How can i convert VB String data type to char*

Thank you,

Regards,
Sreedharan

How To Convert Chinese Char To UTF 16 Format.
Hi guys,

I am trying to develop a SMS based application, through which chinese chars are to be sent. So, I need to change it in UTF16 format. Can anybody help me how to make it?

sandip

How To Convert Chinese Char To UTF16
Hi Guys,

I am making an application which sends SMS via SMPP, so I need to convert chinese char into UTF16 format.

Please help me, how to convert chinese to UTF16.

Convert MSSQL Datetime Field To Char
How can I convert a MSSQL datetime field value to a normal date en time?
Can anyone help me with this?

Example MSSQL field:

numeric(18,0) = 1202417100000

How to convert the above numeric to a normal date and time.. in vb6??

Transliterate (convert) Foreign Text Into English Char
We need guidance for converting foreign language text into English characters. We just need it in English text, even though it is gibberish. i.e (one English char represents a char in the foreign language.)

Thanks.

Convert .wav To ASCII
Hi,
I would like to convert a file in wav format into txt format, so to obtain a vector of numbers to create a graphic, with a program, like excel, that is not Matlab.
Exactly I've an algorithm in Visual Basic that analyses a vector of points (graphic) and then gives me in output a series of parameters.
In matlab this is easy, because it recognizes wav files but if I would like to do the same thing in Ms Access, I've to convert before, the wav file in txt file so that my algorithm in Visual Basic can analyse it.
Anyone knows if there exist some algorithm or code that convert wav files in ASCII text files?
Thanks
Bernd

Convert Ascii To Hex
ok i know to convert hex to ascii is simply Val("&h" & hexvalue), but how do you convert ascii to hex? using somthing simple like that (if existant), maybe i just need sleep to realize how to do it but right now i cant think of how to do it. help!!!

Convert *.Wav To ASCII
Is there a way to convert a *.wav file to a ASCII text that contains the sound in a numerical way. I also want to know the otherway around (converting ASCII to *.wav)
I f there's anybody who has a idee please let me know

Thanks

Christian

Convert CSV To ASCII
I am trying to take a CSV file and convert it to ASCII. Any suggestions?

How To Convert Raw Binary Into Ascii Hex
i need to know how to convert raw binary into ascii hex, i searched around but couldnt find anything on it. anyone know?

Convert 5 Lines Of Hex To ASCII
OK, I have been reading up on ASCII but still can not get this right.
My app reads from a device on com port that sends 5 lines of ASCII code
Example

Quote:




49 02 01 00 00 00 31
49 02 02 47 36 4B 44
49 02 03 35 34 59 58
49 02 04 32 55 31 33
49 02 05 34 38 33 32

>





Which I need decoded to

Quote:




1g6kd54yx2u134832






The documentation I have found says this

Quote:




Returns 5 lines, A is line ordering flag, B-E ASCII coded VIN Digits





So I guess the 49 02 of each line is to be ignored?
and the rest needs to be converted?

Below is a screen shot of the message I received today

Convert A Word To Ascii
Hi peeps i was wondering if anyone can help me with this problem.

i am making a program to convert words to ascii and then display the ascii in a textbox

i can make it convert 1 letter of the word only. is there anyway to make it convert the whole word into ascii

thx

Convert Characters To Ascii No.
i have an array called chars(). when my program runs, 1 character is stored in each variable of the array eg. chars (0) stores 1 character, chars(1) stores 1 character and so on. i heard that there are 256 ascii characters, is there a simple and fast way to convert each character into its ascii number, say chars(0) had the letter u stored in it and the number of u was 132 then chars(0) would be changed to 132
thanks

How To Convert It To ASCII File
I download a log file from SUN server,if i open it with notpad,it looks like: ???? % @#w./.....; it's a binary file , my custumer can't read it unless it is a ASCII file.so i want to know how to convert it to ASCII file readable with .TXT or .XLS


maybe I should use following :
open "d:log001" For Binary As 1
...
...
Get .....
...
Close 1
Open "d:
esult.txt" For Random As 1
.....
Put ...

but it's difficult to know the rule of binary file,
any advice is very useful to me!thanks

Convert Ascii To Binary
Hi all.
I have a bit of a problem. I am getting a value from an OCX and it is in ascii. How can I convert the string so that it shows the binary representation of these values?

I.E. I get the value "Hi" "H" is 072 ascii and "i" is 105 ascii.

Then turning and converting those values to binary so that I get

"010010001101001" the binary equivilant.

Any help would be GREATLY appreciated

Convert String To ASCII
How would I go about converting a string into and ASCII string. Just for an example, say I had the string apple (the ascii characters arent right)

Apple
a=4 p=7 p=7 l=2 e=1
Then the ascii string would be 47721

Anyone?

Thanks

Convert KeyCode To Ascii
How can I convert KeyCode and Shift to ascii under the KeyDown event?

I understand that not all the keys even convert, but I would like to be able to get lower and upper case letters, numbers, backspace, and enter.

I cannot use the keypress event.

Thanks!

Convert Binary To ASCII
I'd like to convert binary code into ASCII. Does anyone have any code that could pull that off?? Thanx in advance!

How To Convert Ascii Into Binary
Hi,
I want to know that how we can convert our ascii text into binary one.

Convert Ascii To Text
i can convert text to ascii using asc(), but how do i reverse it?

Convert Hex? Decimal? Ascii??
**



Edited by - Marce22 on 6/1/2005 11:23:36 AM

Convert Ascii String To Hex
Hi. I am having a problem finding the syntax to convert a 2 charactor String to a Hex value. The String will always be 2 charactors in length and will have ascii values from 00 to FF. Once in Hex, I will be using the value to set the .Height value of a Shape (Rectangle) which will represent the signal strength of a radio receiver. The receiver reports the signal level as a 2 charactor String, 00 to FF. I have tried a few different things and var types but keep getting a Type Mismatch.

Dim Signal_Level_Rec_A As Variant

Private Sub RecAComm_OnComm()
    Select Case RecAComm.CommEvent
        ' Errors
      Case comEventBreak ' A Break was received.
      Case comEventFrame ' Framing Error
      Case comEventOverrun ' Data Lost.
      Case comEventRxOver ' Receive buffer overflow.
      Case comEventRxParity ' Parity Error.
      Case comEventTxFull ' Transmit buffer full.
      Case comEventDCB ' Unexpected error retrieving DCB]

   ' Events
      'Case comEvCD ' Change in the CD line.
      'Case comEvCTS ' Change in the CTS line.
      'Case comEvDSR ' Change in the DSR line.
      'Case comEvRing ' Change in the Ring Indicator.
      Case comEvReceive ' Received RThreshold # of chars.
        Do
            DoEvents
            Comm_Recd_Rec_A = Comm_Recd_Rec_A & RecAComm.Input
        Loop Until InStr(Comm_Recd_Rec_A, vbCrLf) 'wait to receive <CR><LF> from receiver
        'Loop Until Len(Comm_Recd_Rec_A) = 4
        temp = Len(Comm_Recd_Rec_A)
        Comm_Recd_Rec_A = Right(Comm_Recd_Rec_A, temp - 1) 'strip off leading char.
        Comm_Recd_Rec_A = Left(Comm_Recd_Rec_A, temp - 3) 'strip off trailing CF,LF
         
        Rec_A_Meter_Comm_Rec.Caption = Comm_Recd_Rec_A
        If Left(Comm_Recd_Rec_A, 2) = "G0" Then 'status data follows
            DoEvents
        ElseIf Left(Comm_Recd_Rec_A, 2) = "G2" Then 'comm protovol version data follows
            DoEvents
        ElseIf Left(Comm_Recd_Rec_A, 2) = "GE" Then 'destination country data follows
            DoEvents
        ElseIf Left(Comm_Recd_Rec_A, 2) = "H9" Then 'scan status data follows
            DoEvents
        ElseIf Left(Comm_Recd_Rec_A, 2) = "I1" Then 'S-meter data follows 'This Case for Signal Level
            Signal_Level_Rec_A = Right(Comm_Recd_Rec_A, 2)
            Call Rec_A_Signal_Meter
        ElseIf Left(Comm_Recd_Rec_A, 2) = "I2" Then 'Center meter data follows
            DoEvents
        ElseIf Left(Comm_Recd_Rec_A, 2) = "I3" Then 'DTMF data follows
            DoEvents
        ElseIf Left(Comm_Recd_Rec_A, 2) = "NE" Then 'bandscope buffer data follows
            DoEvents
        End If '* add busy status I0/
             
      'Case comEvSend 'There are SThreshold number of characters in the transmit buffer
                      
      'Case comEvEOF ' An EOF charater was found in the input stream
                      
    End Select
    Comm_Recd_Rec_A = "" 'clear buffer
End Sub

Private Sub Rec_A_Signal_Meter() 'bargraph for Signal strength
    Dim temp As Byte
    temp = Signal_Level_Rec_A 'Trouble is here
    Rec_A_Meter_Signal_Level_Shape.Height = temp '* 3 'Signal_Level_Rec_A
    Rec_A_Meter_Signal_Level_Shape.Top = 1380 - Rec_A_Meter_Signal_Level_Shape.Height
End Sub '^ this number sets bottom position of bargraph


 

Convert Binary To Ascii
I am not familiar with binary file access, so forgive me if this is obvious:

When opening and reading a binary file, how do you convert it to Ascii?

How To Convert Extended Ascii To Hexadecimal?
Dear Friends

I am using Visual Basic 6.0. I have to convert Extended Ascii(Characters having ascii values > 127) into hexadecimal while interfacing an Electronic equipment. Please guide me on this.

Thanks in advance,
dpr

Convert Text File To Ascii
Does anyone have some code out there that will convert a text file to an ascii file????

Convert ASCII To Unicode And Back??
This may be much simpler than I think, but I haven't found an answer yet...

I need to convert ASCII characters to Unicode and back.

I'm looking to get the actual code that I can use, say in a web app. i.e. "u00e9" (I understand I'll have to add the 'u' myself...)

So, how can I input "A" and get the correct unicode equivalent?

Thanks.

Copyright © 2005-08 www.BigResource.com, All rights reserved