Results 1 to 3 of 3

Thread: StrPtr - Converting from VB 6.0 to VB.Net

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Angry StrPtr - Converting from VB 6.0 to VB.Net

    Hi, I am trying to convert a code from VB 6.0 to VB.Net, but there is one function that seems to cause a hang up. Can anyone point me in the right direction? I have placed the VB 6.0 code here, and I have tried running/building it in VB.Net but .Net does not seem to read the StrPtr function. Can anyone help me out? or convert this code for me? Thank you very much.


    Public Sub SendScriptToArcPad(ByRef strScript As String)

    Dim cds As COPYDATASTRUCT
    cds.dwData = 1
    cds.cbData = Len(strScript) + 2

    cds.lpdata = StrPtr(strScript) ' HERE IS THE PROBLEM!

    Call SendMessage(hArcPad, WM_COPYDATA, VariantType.Null, cds)
    Call ShowWindow(hArcPad, SW_SHOWMAXIMIZED)

    End Sub

  2. #2
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    Re: StrPtr - Converting from VB 6.0 to VB.Net

    We would probably need to see more of the code to help you.

    Reason being that StrPtr simply doesn't exist anymore in VB on the .net platform. You can probably still do whatever you are trying to do, but the code may be totally different to do it.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2005
    Posts
    11

    Cool Re: StrPtr - Converting from VB 6.0 to VB.Net

    Ok Matt, thanks for looking at this. Here is the whole code (it was written in VB 6.0 and I am trying to run it in VB.Net). The error is near the bottom (where I use StrPtr).



    Option Strict Off
    Option Explicit On
    Module VBWin32

    Public Declare Function FindWindow Lib "user32" Alias "FindWindowA"(ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

    Public Declare Function SendMessage Lib "user32" Alias "SendMessageW" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByRef Param As Object) As Integer

    Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Integer, ByVal nCmdShow As Integer) As Integer


    'Win32 API Constants
    Public Const WM_COPYDATA As Short = &H4As
    Public Const SW_SHOWMAXIMIZED As Short = 3
    Public Const WM_APP As Short = &H8000s

    'ArcPad API Constants
    Public Const APCLASS As String = "AfxArcPad Class"
    Public Const WM_ARCPAD As Integer = WM_APP + &H100s

    'Handle to the ArcPad Window
    Public hArcPad As Integer

    'UDT for COPYDATA structure
    Public Structure COPYDATASTRUCT
    Dim dwData As Integer
    Dim cbData As Integer
    Dim lpdata As Integer
    End Structure


    Public Function IsArcPadRunning() As Object

    '****Returns True if ArcPad is currently running********
    '****Returns False is ArcPad is not currently running***


    'hArcPad is declared as a public variable
    hArcPad = FindWindow(APCLASS, vbNullString)

    If hArcPad = 0 Then 'UPGRADE_WARNING: Couldn't resolve default property of object IsArcPadRunning. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'

    IsArcPadRunning = False
    MsgBox("ArcPad is not currently running!", MsgBoxStyle.Critical, "ArcPad Not Running")

    Else
    'UPGRADE_WARNING: Couldn't resolve default property of object IsArcPadRunning. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'

    IsArcPadRunning = True
    End If
    End Function

    Public Sub SendScriptToArcPad(ByRef strScript As String)
    Dim cds As COPYDATASTRUCT
    cds.dwData = 1
    'UPGRADE_ISSUE: LenB function is not supported. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'

    cds.cbData = Len(strScript) + 2

    'UPGRADE_ISSUE: StrPtr function is not supported. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1040"'

    cds.lpdata = StrPtr(strScript)
    'Send the script to ArcPad
    'UPGRADE_WARNING: Couldn't resolve default property of object cds. Click for more: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'

    Call SendMessage(hArcPad, WM_COPYDATA, VariantType.Null, cds)
    'Maximize the ArcPad window

    Call ShowWindow(hArcPad, SW_SHOWMAXIMIZED)
    End Sub
    End Module

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width