Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get ANSI character code for input character

Status
Not open for further replies.

crackoo

Programmer
Feb 17, 2011
132
TN
Hi
i have this source to get ANSI character code for input character
so my aim is how can i modify this code to show on the inputBox the hole string for exemple when i typed on the inputbox "vbscript" it show me like this in one line "chr(118)&chr(98)&chr(115)&chr(99)&chr(105)&chr(112)&chr(116)"
Thank you !
Code:
i = InputBox("Enter character to get ANSI character code.") 
If i <> "" Then 
Inputbox "ANSI Code for " & i & " is:",,"Chr(" & Asc(i) & ")" 
End If




 



crackoo (Programmer),

Use a For...Next loop and the Mid() function to loop thru each character of your string.

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Problem Solved Thank you for the reply an your idea !
Code:
Dim i,x,a 
i = InputBox("Enter character to get ANSI character code.") 
If i <> "" Then 
For x = 1 To Len(i) 
If x <> Len(i) Then 
a = a & "Chr(" & Asc(Mid(i,x,1)) & ")" & "&" 
Else 
a = a & "Chr(" & Asc(Mid(i,x,1)) & ")" 
End if 
Next 
Inputbox "ANSI Code for " & i & " is:",,a 
End If 
MsgBox Chr(84)&Chr(104)&Chr(97)&Chr(110)&Chr(107)&Chr(32)&Chr(121)&Chr(111)&Chr(117)&Chr(32)&Chr(74)&Chr(118)&Chr(105)&Chr(101)&Chr(114)&Chr(114)&Chr(97)&Chr(32)&Chr(33),64,"ANSI CODE"
MsgBox Chr(84)&Chr(104)&Chr(97)&Chr(110)&Chr(107)&Chr(32)&Chr(121)&Chr(111)&Chr(117)&Chr(32)&Chr(83)&Chr(107)&Chr(105)&Chr(112)&Chr(86)&Chr(111)&Chr(117)&Chr(103)&Chr(104)&Chr(116)&Chr(32)&Chr(33),64,"ANSI CODE"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top