Solved

Comparing strings and byte arrays

Posted on 2000-04-25
3
340 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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code 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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now