conversion

Azrael III
07-20-2003, 03:55 AM
is it possible to convert strings to constants?

eg if a user types "A" in a textbox the prog should read "vbKeyA"

is this possible

AndreRyan
07-20-2003, 04:31 AM
vbKeyA is the same as Asc("A")
If Asc("A")=vbKeyA Then 'Always true

To convert to ASCII numbers

Dim i as integer
For i = 1 To Len(text1.text)
Text2.text=Text2.text & Asc(Mid(Text1.text, i, 1)) & Space(1)
Next i

RoySchreiber
07-20-2003, 04:34 AM
text1.text=keycode

Azrael III
07-20-2003, 05:07 AM
thx to all
but now:
next question:
is it also possible to give the name of the constants instead of asciicodes?

Iceplug
07-20-2003, 05:39 AM
I don't think so...
You'd probably need to use a Select Case for that.
[vb]
Select Case X
Case "A" To "Z", "0" To "9"
Constname = "vbKey" & X
Case " "
Constname = "vbKeySpace"
Case vbCr, vbLf
Constname = vbKeyReturn
End Select
And then, not all keys are represented here. :(

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum