1

is there any to convert a string into Hex using Vb-script?

here there is a simple guide doing this, but it seems it works only for numbers not alphabets.

http://www.w3schools.com/vbscript/func_hex.asp

5
  • If your input string is "abc 123", what do you expect as output? And what have you attempted to get it? Commented Jun 16, 2014 at 7:30
  • for "abc 123" output should be "61 62 63 20 31 32 33". Commented Jun 16, 2014 at 7:32
  • possible duplicate of Char to UTF code in vbscript Commented Jun 16, 2014 at 8:07
  • Try a search engine: duckduckgo.com/?q=vbscript+string+character+code+hex Commented Jun 16, 2014 at 8:07
  • msgbox Hex(Asc("A")). You have to do it character by character. Commented Jun 16, 2014 at 9:03

1 Answer 1

4

Here it is:

strString = "test"
strHex =""
For i=1 To Len(strString)
    strHex = strHex + Hex(Asc(Mid(strString,i,1)))
Next

WScript.Echo strHex
Sign up to request clarification or add additional context in comments.

1 Comment

Best to use & instead of + for string concatenation. Don't make VBScript guess whether 10 + 20 should be 1020 or 30.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.