Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / October 2007

Tip: Looking for answers? Try searching our database.

AddressOf Problem with vb6 to .NET 2005 Conversion

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
JOHNDOE@EMAIL.COM - 15 Oct 2007 20:58 GMT
All right, I've been trying to wrap my head around this by reviewing
what is out on the web but still seem to be struggling with this....
Here is the calling code with the AddressOf Error:

    Private Sub cmdInitialize_Click(ByVal eventSender As System.Object,
ByVal eventArgs As System.EventArgs) Handles cmdInitialize.Click

        Dim oCtl As System.Windows.Forms.Control

        Debug.Print("------------------- Begin DDE Test
-----------------------")

        g_lInstID = 0

        ' Initialize the DDE subsystem. This only needs to be done once.
        'UPGRADE_WARNING: Add a delegate for AddressOf DDECallback Click for
more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?
keyword="E9E157F7-EF0C-4016-87B7-7D7FBBC6EE08"'
       'If DdeInitialize(g_lInstID, AddressOf DDECallback,
APPCMD_CLIENTONLY Or MF_SENDMSGS Or MF_POSTMSGS, 0) Then
       If DdeInitialize(g_lInstID, AddressOf DDECallback,
APPCMD_CLIENTONLY Or MF_SENDMSGS Or MF_POSTMSGS, 0) Then

           Debug.Print("DDE Initialize Failure.")
           TranslateError()

       Else

           Debug.Print("DDE Initialize Success.")

       End If

       'Enable the command buttons.
       For Each oCtl In Controls

           'UPGRADE_WARNING: TypeOf has a new behavior. Click for
more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?
keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
           If ((TypeOf oCtl Is System.Windows.Forms.TextBox) Or
(TypeOf oCtl Is System.Windows.Forms.ComboBox)) And (oCtl.Enabled =
False) Then
               oCtl.Enabled = True
           End If

       Next oCtl

       cmdInitialize.Enabled = False
       cmdUninitialize.Enabled = True
       cmdClear.Enabled = True
       cboItem.SelectedIndex = 0

Here is the function that I am calling:
 Public Function DDECallback(ByVal uType As Integer, ByVal uFmt As
Integer, ByVal hConv As Integer, ByVal hszString1 As Integer, ByVal
hszString2 As Integer, ByVal hData As Integer, ByVal dwData1 As
Integer, ByVal dwData2 As Integer) As Integer

       Dim lSize As Integer
       Dim sBuffer As String
       Dim Ret As Integer

       Debug.Print("In client callback. uType: " & uType)

       Select Case uType

           ' This is th eevent you'll receive when a server sends you
a advisment.
           Case XTYP_ADVDATA
               Debug.Print("XTYP_ADVDATA")

               lSize = DdeGetData(hData, vbNullString, 0, 0)

               ' If size is 0 then there's no data to grab.
               If (lSize > 0) Then

                   ' Allocate a buffer for the return data.
                   sBuffer = New String(Chr(0), lSize - MAGIC_NUMBER)

                   ' Grab the data.
                   lSize = DdeGetData(hData, sBuffer, Len(sBuffer),
0)

                   ' Print the contents of the buffer.
                   frmDDEApp.txtValue.Text = sBuffer
               End If

           Case XTYP_ADVSTART
               Debug.Print("XTYP_ADVSTART")

           Case XTYP_ADVSTOP
               Debug.Print("XTYP_ADVSTOP")

           Case XTYP_CONNECT
               Debug.Print("XTYP_CONNECT")

           Case XTYP_CONNECT_CONFIRM
               Debug.Print("XTYP_CONNECT_CONFIRM")

           Case XTYP_DISCONNECT
               Debug.Print("XTYP_DISCONNECT")

           Case XTYP_ERROR
               Debug.Print("XTYP_ERROR")

           Case XTYP_EXECUTE
               Debug.Print("XTYP_EXECUTE")

           Case XTYP_MASK
               Debug.Print("XTYP_MASK")

           Case XTYP_MONITOR
               Debug.Print("XTYP_MONITOR")

           Case XTYP_POKE
               Debug.Print("XTYP_POKE")

           Case XTYP_REGISTER
               Debug.Print("XTYP_REGISTER")
               g_hService2 = hszString2

               lSize = DdeQueryString(g_lInstID, hszString2,
vbNullString, 0, CP_WINANSI)
               sBuffer = Space(lSize)
               DdeQueryString(g_lInstID, hszString2, sBuffer, lSize +
1, CP_WINANSI)

               sBuffer = UCase(sBuffer)

           Case XTYP_REQUEST
               Debug.Print("XTYP_REQUEST")

           Case XTYP_SHIFT
               Debug.Print("XTYP_SHIFT")

           Case XTYP_UNREGISTER
               Debug.Print("XTYP_UNREGISTER")

           Case XTYP_WILDCONNECT
               Debug.Print("XTYP_WILDCONNECT")

           Case XTYP_XACT_COMPLETE
               Debug.Print("XTYP_XACT_COMPLETE")

       End Select

       DDECallback = 0

   End Function

Thanks to everyone for their help!

-Kurt
Tom Shelton - 16 Oct 2007 00:18 GMT
On Oct 15, 1:58 pm, "JOHN...@EMAIL.COM" <kurth...@gmail.com> wrote:
> All right, I've been trying to wrap my head around this by reviewing
> what is out on the web but still seem to be struggling with this....
[quoted text clipped - 148 lines]
>
> -Kurt

Kurt,

The compiler is wanting you to declare a delegate for the ddecallback
function.  It would look something like (assuming your function
signiture is correct):

Public Delegate Function DDECallbackDelegate _
   (ByVal uType As Integer, _
    ByVal uFmt As Integer, _
    ByVal hConv As Integer, _
    ByVal hszString1 As Integer, _
    ByVal hszString2 As Integer, _
    ByVal hData As Integer, _
    ByVal dwData1 As Integer, _
    ByVal dwData2 As Integer) As Integer

HTH,

--
Tom Shelton

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.