Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Comparing strings and byte arrays

Posted on 2000-04-25
3
Medium Priority
?
385 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 200 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

972 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