Solved

Comparing strings and byte arrays

Posted on 2000-04-25
3
351 Views
Last Modified: 2008-02-26
I want the code below to work. Someone make it work :P

---------------------------------------
Dim cByteArray() as Byte
Dim sString as String

'...
'the values of cByteArray and sString are set
'...

If cByteArrary = sString Then
     MsgBox "It worked!"
End If
---------------------------------------
0
Comment
Question by:core123
  • 2
3 Comments
 

Author Comment

by:core123
ID: 2748965
The part that isn't working is the comparing. In the example above assume both cByteArray and sString have values.
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 50 total points
ID: 2748967
You can assign a byte array to a string:

sString2 = cByteArray

But when you compare them you will have to convert the VB string from unicode

---------

Dim b(1 To 4) As Byte
    Dim ss As String
    Dim sb As String
    Dim i As Integer
   
    For i = 1 To 4
        b(i) = Asc("A")
    Next i
   
    sb = b
    ss = "AAAA"
   
    If sb = StrConv(ss, vbFromUnicode) Then
        MsgBox "Works!"
    End If
0
 

Author Comment

by:core123
ID: 2748975
Edited text of question.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question