Solved

Comparing strings and byte arrays

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
Suggested Courses
Course of the Month10 days, 15 hours left to enroll

632 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