Link to home
Start Free TrialLog in
Avatar of Sridhar Cherukuri
Sridhar CherukuriFlag for Tanzania, United Republic of

asked on

Printing the Ascii values

Hi all i have created a ms-word document in visual basic and trying to print the ascii values of some numbers:

for example i am trying to print % symbol in ms-word document whose ascii value is 37 i am using the following code to do it

Private Sub Form_Load()
n = 37
fname = "c:\ascii.doc"
Open fname For Output As #1
Print #1, Asc(n) & " - " & n & vbCrLf
Close #1
End Sub

When i execute the above code it is displaying, but instead of printing the % symbol it printing     51 - 37 in ms-word document (ascii.doc) here 51 is asc(n) and 37 is n value.

Can any one kindly help me to solve this problem? I just want to print the various special characters in ms-word document from visual basic program

Thanks and Regards

Sridhar Cherukuri
ASKER CERTIFIED SOLUTION
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Asc() is the inverted funtion, it return the ASCII code of a character:

Asc("%")  ->   37
Chr$(37)  ->   %

Asc(37)  ->  Asc("37")   ->  Asc("3")   ->  51       <--- This is what you are obtaining right now
Why the B grade? Does my explanation cover all your dudes?
B grade is intended to a partial/incomplete answer.
Avatar of Sridhar Cherukuri

ASKER

I am really very sorry friend as i am new i dont know the grading system. i thought A is for extremely difficult question. Is there any way to modify the grading? once again i am sincearly sorry for it

Sridhar
Yes, Community support will help, I'll do it for you.
The difficult grading is related to the points you decide to give, this is at your own criteria.
The grade is related to the satisfaction with the answer.
Thank you for the points and your response.
Good luck,
Jaime.
Thank you both, have a nice day.