Results 1 to 3 of 3

Thread: asc and hex representation

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2001
    Posts
    7
    I have 2 questions now how do i enter a string in using the asc function
    Also how do i convert a decimal number to its hexadecimal equivalent
    again any help would be greatly appreciated

  2. #2
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Asc is good for converting a single character from text to its decimal value.

    To convert a string, this is the most efficient way I know:

    Code:
    Private Sub Command1_Click()
    Dim ba() As Byte
    Dim s As String
    Dim i%
    
    s = "abc"
    s = StrConv(s, vbFromUnicode)
    ba = s
    
    'now you have an array with every character expressed As a Single byte.  we just need To extract the value
    For i = 0 To UBound(ba)
        MsgBox ba(i) 'give Decimal value of Each character
    Next

    End Sub

  3. #3
    Fanatic Member
    Join Date
    Nov 2000
    Location
    Sydney Australia
    Posts
    804
    Same use hex$ to get hex value:

    Code:
    Private Sub Command1_Click()
    Dim ba() As Byte
    Dim s As String
    Dim i%
    
    s = "hello In hex"
    s = StrConv(s, vbFromUnicode)
    ba = s
    'now you have an array with every character In it
    For i = 0 To UBound(ba)
        MsgBox Hex$(ba(i)) 'give hex value of Each character
    Next
    
    
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width