473,385 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help request about copymemory

Hi all.
I should migrate old vb6 code in vb.net but I been clashed with the copymemory api!
Here below is a vb6 method that manages the current sample of a waveform file in a buffer for retrieving the left/right volumePictBox level in order to draw the wavegraph of that file on a picture box:

Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDst As integer, _
ByVal pSrc As Long, _
ByVal ByteLen As Long)

Private Function GetMono16Sample(ByVal Sample As Long) As Double

Dim Ret as Double
Dim Sample16 As Integer
Dim Ptr As Long = Sample * Gformat.nBlockAlign + BufferAlloc

CopyMemory(sample16, Ptr, 2)
Ret = Sample16 / 32768

Return Ret
End Function

So for example in vb6 the routine above works in the following way:
Costant values:
Gformat.NblockAlign = 2
BufferAlloc = 57560544

Input value:
sample = 0
ptr returned value = 57560544

returned value by CopyMemory:
sample16 = 15

or another example:
Input value:
sample = 10
ptr returned value = 57560564

returned value by CopyMemory:
sample16 = 2

in vb.net the function above (with var.type properly updated), returns the following exception: System.NullReferenceException Reference to an object not set on a object istance(????)

its possible to reproduce its vb6 behaviour on vb.net?
Thank you very much for any kind answer.

Best regards
Andrea
Jun 30 '06 #1
0 1804

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Mike | last post by:
Hi All, I have been struggling with this for weeks now and I just can't get my head around it. I am trying to convert this procedure to VB.NET. In particular I am having problems with the...
6
by: seansan | last post by:
Hi, Does anyone know how to read the full access version number in visual basic? I need to know if the current program instance is SR-1 or SP-3, etc... I currently use: DB_DAO =...
5
by: RaviAmbani | last post by:
I am facing a problem in copymemory api in vb.net . the problem is that i have used copymemory api extensively in my project originally written in vb6.0 , now when i'm migrating my project to...
2
by: William Morgan | last post by:
Public Declare Sub ydec_set_callback Lib "yDecLib.dll" (ByVal CallbackFunc As Long) Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal lpvDest As String, ByVal lpvSource As...
5
by: active | last post by:
Has anyone used CopyMemory with DotNet? In this instance I define it as: Private Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (ByRef hpvDest As DEVMODE, ByRef hpvSource As Byte,...
1
by: Glen Conway | last post by:
Hi, I'm trying to use the gethostbyname function from wsock32.dll and failing dismally Has anyone got a successful implementation of this in VB.NET? My ulitimate goal is to resolve NetBIOS names...
9
by: The Grim Reaper | last post by:
Dear Gurus... (Sorry to cross post... but...) I have a dire problem - been working on this for days now. It's the undocumented API's for NTDLL.dll - namely NtOpenSection, NtMapViewOfSection,...
10
by: Dennis | last post by:
I am trying to use CopyMemory to copy arrays as follows: Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByVal pDst As Long, ByVal pSrc As Long, ByVal ByteLen As Integer) ...
43
by: ZillionDollarSadist | last post by:
Hello, I'm working at a simple Access '97 + VB4 application, and I ran into a terrible problem: something I never modified now gives me a totally unwanted "Invalid use of null" error. It happens...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.