Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Convert string to binary?

Hi-
I have a VBScript function designed to convert a string to binary, however when I try to view the output in a browser it just shows me the text I entered. I'm trying to convert the text to binary and view it. Can anyone help?

<%
Function StringToBinary(S)
Dim i, ByteArray
For i=1 To Len(S)
ByteArray = ByteArray & ChrB(Asc(Mid(S,i,1)))
Next
StringToBinary = ByteArray
End Function

Response.BinaryWrite StringToBinary(strFormData) & "<P>"
%>


Thanks!

Comments

  • vanithvanith Member Posts: 44
    [b][red]This message was edited by vanith at 2002-10-7 14:43:19[/red][/b][hr]
    : Hi-
    : I have a VBScript function designed to convert a string to binary, however when I try to view the output in a browser it just shows me the text I entered. I'm trying to convert the text to binary and view it. Can anyone help?
    :
    : <%
    : Function StringToBinary(S)
    : Dim i, ByteArray
    : For i=1 To Len(S)
    : ByteArray = ByteArray & ChrB(Asc(Mid(S,i,1)))
    : Next
    : StringToBinary = ByteArray
    : End Function
    :
    : Response.BinaryWrite StringToBinary(strFormData) & "<P>"
    : %>
    :
    :
    : Thanks!
    :

    Is there a function as ChrB() in VBScript or are you trying to use CByte() function?

    :)heers,
    Vanith


  • jdg56jdg56 Member Posts: 6
    : [b][red]This message was edited by vanith at 2002-10-7 14:43:19[/red][/b][hr]
    : : Hi-
    : : I have a VBScript function designed to convert a string to binary, however when I try to view the output in a browser it just shows me the text I entered. I'm trying to convert the text to binary and view it. Can anyone help?
    : :
    : : <%
    : : Function StringToBinary(S)
    : : Dim i, ByteArray
    : : For i=1 To Len(S)
    : : ByteArray = ByteArray & ChrB(Asc(Mid(S,i,1)))
    : : Next
    : : StringToBinary = ByteArray
    : : End Function
    : :
    : : Response.BinaryWrite StringToBinary(strFormData) & "<P>"
    : : %>
    : :
    : :
    : : Thanks!
    : :
    :
    : Is there a function as ChrB() in VBScript or are you trying to use CByte() function?
    :
    : :)heers,
    : Vanith
    :
    :
    :
    Yes, there is a function ChrB() in VBScript...any ideas?
    Thanks!
  • Anjuna MoonAnjuna Moon Member Posts: 89
    Well, to start with using chr or chrb in conjunction with asc just neutrolizes the operation, i.e chrb(asc("a")) is 'a'
    Remove the chrb, and your result will be a string of ascii-values. Is that what you wanted? (eg. "AB" would generate "6566")
    /Chris
  • Shawn CarterShawn Carter Member Posts: 0

    _______ || http://forcoder.org || free video tutorials and ebooks about [ Visual Basic .NET PL/SQL Java Assembly PHP JavaScript Objective-C C MATLAB Perl Ruby R C++ Swift Scratch Delphi Python Go C# Visual Basic Transact-SQL Alice Rust Bash Scala Fortran Scheme Lisp COBOL Apex Prolog Julia D ABAP F# SAS Awk VBScript Erlang Kotlin Dart Clojure Hack ML LabVIEW Crystal FoxPro Lua Logo Ada ] ____

Sign In or Register to comment.