Top DevX Stories
Creating Custom Export Filters for StarOffice with XSLT
WPF Wonders: Using DataTemplates
Crystal Reports Family Offers Options for Developers
Avaya Aura Session Manager video
Avaya Aura Overview video
Search the forums:

Go Back   DevX.com Forums > DevX Developer Forums > VB Classic

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 10-18-2009, 08:58 AM
Alphadan Alphadan is offline
Registered User
 
Join Date: Jun 2007
Posts: 86
String Variable Layout and copyMemory

hi everyone

im trying to read 2 numbers stored in string, but they are a string representation of a 16 bytes integer, they mean coordinates for example.

i have this "¹K ¬K" from 0 to 2 is the X coordinate, and from 4 to 6 is the Y coordinate.

if these bytes were in a byte array would be simple to get the integer number, just copyng from pos 0 to 2 to the memory of a integer variable, would give me the x coordinate and 4 to 6 the y one.

but in the string the data is stored as unicode and they have 4 bytes(reserved) at the beginning for storing its lenght so i would be using bytes from 4 and up.

but how would be a easy way to get those numers from the strings?


Thx in advance!!!
Reply With Quote
  #2  
Old 10-18-2009, 11:01 AM
vb5prgrmr vb5prgrmr is offline
Registered User
 
Join Date: Jun 2009
Posts: 46
Okay, to convert from unicode to ansi use strconv function with the vbFromUnicode as the parameter...



Good Luck
Reply With Quote
  #3  
Old 10-19-2009, 01:54 AM
Alphadan Alphadan is offline
Registered User
 
Join Date: Jun 2007
Posts: 86
Quote:
Originally Posted by vb5prgrmr View Post
Okay, to convert from unicode to ansi use strconv function with the vbFromUnicode as the parameter...



Good Luck
would that change the layout of string variable on memory? i think it wont but thx for the answer, i alreasy solved that just using a loop to convert it hehe i was avoiding that cause is slow, but still ok, now i have a trouble cause isnt a integer as i tought is a mini float a 2 bytes floating point and cannot obtain the alue =(.
Reply With Quote
  #4  
Old 10-19-2009, 03:10 AM
vb5prgrmr vb5prgrmr is offline
Registered User
 
Join Date: Jun 2009
Posts: 46
No it should not change the value in memory as it is meant to read from one variable into another. Glad you have it solved...



Good Luck
Reply With Quote
  #5  
Old 10-19-2009, 05:56 AM
Alphadan Alphadan is offline
Registered User
 
Join Date: Jun 2007
Posts: 86
here is the code to convert to float, if someone else needs it.

the same can be done to double, long, integer etc just change the varyable type of the dest on copymemory and of course the bytes selection lenght of copymemory.

Code:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)


Sub ConvertBytesToSingle(DArr() As Byte, float As single)
'for Byte arrays with 1 as minimun index
  CopyMemory float, 1, 4
End Sub
Reply With Quote
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 08:03 AM.


Sponsored Links



Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.