|
-
Oct 10th, 2001, 06:53 AM
#1
Thread Starter
Frenzied Member
Memory Moving
I need to put a byte array of ASCII character codes into a standard VB string.
Any ideas?
so . ..
MyString = MyBytes()
would be the assignment I would like to achieve. The above code doesn't work, of course!
Cheers chaps
-
Oct 10th, 2001, 07:23 AM
#2
PowerPoster
This any good?
VB Code:
Dim i As Long
Dim MyBytes() As Byte
Dim strString As String
For i = 0 To UBound(MyBytes)
strString = strString & MyBytes(i)
Next i
MsgBox strString
-
Oct 10th, 2001, 07:29 AM
#3
Thread Starter
Frenzied Member
The application I am trying to do is buffered screen displays. So for instance I have a console window of 78 x 50. This is displayed in a text box, so really I am trying to assign the byte array (2 dimensional) to the .Text property of the textbox.
I currently do it the way you suggest, but to me it feels clumsy. I have tried CopyMemory (Aka RtlMoveMemory) but this doesn't appear to work.
I really need more ideas . . .
-
Oct 10th, 2001, 08:56 AM
#4
You cannot CopyMemory to the .Text property because it is actually the argument of a function, not a string array.
Chrisjk gave you a good answer. Consider locking update on the control while you're moving stuff in there. Speeds things up a lot.
-
Oct 10th, 2001, 08:56 AM
#5
New Member
You can use this function to copy a byte array to a string.
DataSize = Length of string
Code:
Public Function GetString(ByRef Data() As Byte, ByVal DataSize As Long) As String
GetString = Space$(DataSize)
CopyMemory ByVal GetString, Data(0), DataSize
End Function
Hope this helps,
Pieter
-
Oct 10th, 2001, 09:58 AM
#6
Thread Starter
Frenzied Member
I've got it working on one dimensional bytes arrays - but not on two dimensions.
I really want to use RtlMoveMemory, I just can't figure out how to coerce the damn array in.
[When I said .Text, it was for clarity - I put it in a local string first]
-
Oct 11th, 2001, 07:16 AM
#7
Thread Starter
Frenzied Member
I am now using the 'TextOut' API function. This allows direct mappings of strings to DC's
Perfect.
Cheers for your help
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|