INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

VB 6 and CopyMemory call

VB 6 and CopyMemory call

(OP)
My problem I'm having is everytime i call the CopyMemory i get a GPF and crashes my app.  ANY help would be greatly appreciated.  Here is my code:

Declare Function BTRCALL Lib "w3btrv7.dll" (ByVal OP, ByVal Pb$, Db As Any, DL As Integer, Kb As Any, ByVal Kl, ByVal Kn) As Integer
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)


Type typ_byte4
    f1(1 To 4) As Byte
End Type


Type RecordBuffer
    Junk1 As String * 6
    MilID As String * 10
    MilNumber As String * 2
    MilSymbol As String * 1
    MilDesc As String * 40
    MilWeight As String * 8
    MilSchedDate As Long
    MilForcastDate As Long
    MilCompleteFlag As String * 1
    MilPctComplete As String * 3
    MilWBS As Long
    Junk2 As String * 7
End Type

Type RecordBufferTodd
    Junk1 As String * 6
    MilID As String * 10
    MilNumber As String * 2
    MilSymbol As String * 1
    MilDesc As String * 40
    MilWeight As String * 8
    MilSchedDate As typ_byte4
    MilForcastDate As typ_byte4
    MilCompleteFlag As String * 1
    MilPctComplete As String * 3
    MilWBS As typ_byte4
    Junk2 As String * 7
End Type

Global DataBufVB As RecordBuffer
Global DataBuf As RecordBufferTodd
Global BufLen As Integer
Global DBLen As Integer

Sub RunTest()
    
    
    'FileName$ = CurrentProject.Path & "\Todda.mil"
    FileName$ = "z:\acct\mpm\wld1\Todda.mil"
    
    PosBlk$ = Space$(128)
    KeyBuffer$ = Space$(KEY_BUF_LEN)
    
    
    'Open File
    KeyBufLen = KEY_BUF_LEN
    KeyBuffer$ = FileName$
    BufLen = Len(DataBuf)
    KeyNum = 0
    
    status = BTRCALL(BOPEN, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)
    
    'Get First Record
    BufLen = Len(DataBuf)
    KeyBuffer$ = Space$(255)
    KeyBufLen = KEY_BUF_LEN
    
    status = BTRCALL(BGETFIRST, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)
    
    Do While (status = 0)
        status = BTRCALL(BGETNEXT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)
        GoSub AddRecord
    Loop

    Exit Sub
    
AddRecord:
    DataBufVB.Junk1 = DataBuf.Junk1
    DataBufVB.Junk2 = DataBuf.Junk2
    DataBufVB.MilCompleteFlag = DataBuf.MilCompleteFlag
    DataBufVB.MilDesc = DataBuf.MilDesc
    DataBufVB.MilID = DataBuf.MilID
    DataBufVB.MilNumber = DataBuf.MilNumber
    DataBufVB.MilPctComplete = DataBuf.MilPctComplete
    DataBufVB.MilSymbol = DataBuf.MilSymbol
    DataBufVB.MilWeight = DataBuf.MilWeight
    
    CopyMemory DataBuf.MilForcastDate, ByVal DataBufVB.MilForcastDate, 4
     
    Return
End Sub

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close