Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Comparing strings and byte arrays

Posted on 2000-04-25
3
Medium Priority
?
375 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

721 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